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
计算机程序设计艺术
Donald E.Knuth / 苏运霖 / 机械工业出版社 / 2006-4 / 45.00元
《计算机程序设计艺术》(经典计算机科学著作最新版)(第1卷第1册双语版)更新了《计算机程序设计艺术,第1卷,基本算法》(第3版),并且最终将成为该书第4版的一部分。具体地说,它向程序员提供了盼望已久的MMIX,代替原来的MIX的一个以RISC为基础的计算机,并且描述了MMIX汇编语言。一起来看看 《计算机程序设计艺术》 这本书的介绍吧!