Python zfill()方法
Python 教程
· 2019-02-02 19:44:48
描述
Python zfill() 方法返回指定长度的字符串,原字符串右对齐,前面填充0。
语法
zfill()方法语法:
str.zfill(width)
参数
- width -- 指定字符串的长度。原字符串右对齐,前面填充0。
返回值
返回指定长度的字符串。
实例
以下实例展示了 zfill()函数的使用方法:
#!/usr/bin/python str = "this is string example....wow!!!"; print str.zfill(40); print str.zfill(50);
以上实例输出结果如下:
00000000this is string example....wow!!! 000000000000000000this is string example....wow!!!
点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html
The Art and Science of Java
Eric Roberts / Addison-Wesley / 2007-3-1 / USD 121.60
In The Art and Science of Java, Stanford professor and well-known leader in CS Education Eric Roberts emphasizes the student-friendly exposition that led to the success of The Art and Science of C. By......一起来看看 《The Art and Science of Java》 这本书的介绍吧!