您当前的位置:首页 > IT编程 > python
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch |

自学教程:Python3 zfill()方法

51自学网 2023-01-08 20:10:55
  python
这篇教程Python3 zfill()方法写得很实用,希望能帮到您。

描述

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

语法

zfill()方法语法:

str.zfill(width)

参数

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

返回值

返回指定长度的字符串。

实例

以下实例展示了 zfill()函数的使用方法:

#!/usr/bin/python3str = "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!!!

Python3 upper()方法
Python3 isdecimal()方法
51自学网,即我要自学网,自学EXCEL、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。
京ICP备13026421号-1