- 用法:- str.zfill(width)
- 返回用 ASCII - '0'数字填充的字符串的副本,以生成长度为- width的字符串。前导符号前缀 (- '+'/- '-') 通过在符号字符而不是之前插入填充- after来处理。如果- width小于或等于- len(s),则返回原始字符串。- 例如: - >>> "42".zfill(5) '00042' >>> "-42".zfill(5) '-0042'
相关用法
- Python str.isidentifier用法及代码示例
- Python str.expandtabs用法及代码示例
- Python str.isupper用法及代码示例
- Python str.title用法及代码示例
- Python str.rstrip用法及代码示例
- Python str.splitlines用法及代码示例
- Python str.lstrip用法及代码示例
- Python str.removeprefix用法及代码示例
- Python str.split用法及代码示例
- Python str.strip用法及代码示例
- Python str.format_map用法及代码示例
- Python str.removesuffix用法及代码示例
- Python str() vs repr()用法及代码示例
- Python string转integer用法及代码示例
- Python string strip()用法及代码示例
- Python string.octdigits用法及代码示例
- Python string.whitespace用法及代码示例
- Python strip()用法及代码示例
- Python str()用法及代码示例
- Python string capitalize()用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 str.zfill。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
