Python3 zfill()方法
Python 3 教程
· 2019-02-06 10:41:47
描述
Python zfill() 方法返回指定长度的字符串,原字符串右对齐,前面填充0。
语法
zfill()方法语法:
str.zfill(width)
参数
- width -- 指定字符串的长度。原字符串右对齐,前面填充0。
返回值
返回指定长度的字符串。
实例
以下实例展示了 zfill()函数的使用方法:
#!/usr/bin/python3
str = "this is string example from codercto....wow!!!"
print ("str.zfill : ",str.zfill(40))
print ("str.zfill : ",str.zfill(50))
以上实例输出结果如下:
str.zfill : this is string example from codercto....wow!!! str.zfill : 000000this is string example from codercto....wow!!!
点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html
Pattern Recognition and Machine Learning
Christopher Bishop / Springer / 2007-10-1 / USD 94.95
The dramatic growth in practical applications for machine learning over the last ten years has been accompanied by many important developments in the underlying algorithms and techniques. For example,......一起来看看 《Pattern Recognition and Machine Learning》 这本书的介绍吧!