我正在尝试将 python 脚本放在运行 micro python 的 pyboard \xe2\x80\x99s 上。MicroPython 中是否有相当于 .zfill 的 python 版本?
\n小智 5
没有内置的 zfill 但我使用这个 zfl 函数
def zfl(s, width):
# Pads the provided string with leading 0's to suit the specified 'chrs' length
# Force # characters, fill with leading 0's
return '{:0>{w}}'.format(s, w=width)
Run Code Online (Sandbox Code Playgroud)
这可能对你有用?只需传递您需要的字符串和字符串宽度即可。
| 归档时间: |
|
| 查看次数: |
1842 次 |
| 最近记录: |