欢迎您 本站地址:  
返回首页   返回编程教学   彩虹屁  照片会说话  男生头像沙雕  网络开发源码  将相故事  调味篇  学习Bootstrap5  学习AngularJS 

Python zfill()方法

Python 字符串 Python 字符串


描述

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

语法

zfill()方法语法:

str.zfill(width)

参数

返回值

返回指定长度的字符串。

实例

以下实例展示了 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 字符串 Python 字符串

小库提示

扫描下方二维码,访问手机版。