logo

zfill函数无法使用

2020-11-29 12:06
I
_3xeb
ba3bbc08-3fbb-4fe0-9727-fe44829d96e5.jpg
2020-11-30 16:16
I
网红小智智 星瞳科技

micropython里没有zfill。

用这个函数代替:

str = "2"

def zfl(s, width):
    return '{:0>{w}}'.format(s, w=width)

print(zfl(str,5))
2020-12-01 19:08
I
_3xeb

@kidswong999 在 [zfill函数无法使用](/post/18150) 中说:

> zfl(str,5)

好的谢谢