69pao国产精品视频-久久精品一区二区二三区-精品国产精品亚洲一本大道-99国产综合一区久久

Python zfill()方法

Python zfill()方法

Python 字符串Python 字符串

Python zfill() 方法返回指定長度的字符串,原字符串右對齊,前面填充0。

 

語法

zfill()方法語法:

str.zfill(width)

 

參數(shù)

  • width -- 指定字符串的長度。原字符串右對齊,前面填充0。

 

返回值

返回指定長度的字符串。

 

實例

以下實例展示了 zfill()函數(shù)的使用方法:

#!/usr/bin/python

str = "this is string example....wow/b64/";

print str.zfill(40);
print str.zfill(50);

以上實例輸出結(jié)果如下:

00000000this is string example....wow/b64/
000000000000000000this is string example....wow/b64/

Python 字符串Python 字符串

下一節(jié):Python 列表 List

Python 教程

相關(guān)文章