码迷,mamicode.com
首页 > 其他好文 > 详细

zfill()方法

时间:2018-12-24 10:28:59      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:idt   --   div   print   strong   ...   fill   code   填充   

zfill()方法

描述

zfill() 方法返回指定长度的字符串,原字符串右对齐,前面填充0。

语法

zfill()方法语法:

S.zfill(width)

参数

  • width -- 指定字符串的长度。原字符串右对齐,前面填充0。

返回值

返回指定长度的字符串。

S = "this is string example from runoob....wow!!!"
print ("S.zfill : ",S.zfill(40))
print ("S.zfill : ",S.zfill(50))

以上实例输出结果如下:

S.zfill :  this is string example from runoob....wow!!!
S.zfill :  000000this is string example from runoob....wow!!!

 

zfill()方法

标签:idt   --   div   print   strong   ...   fill   code   填充   

原文地址:https://www.cnblogs.com/xiaohei001/p/10166657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!