1.rstrip()
str.rstrip([chars])
chars – 指定删除的字符(默认为空格)
返回删除 string 字符串末尾的指定字符后生成的新字符串
例子:
str = "88888888this is string example....wow!!!8888888";
print str.rstrip('8');
输出:
88888888this is string example....wow!!!
2.zfill()
str.zfill(width)
width – 指定字符串的长度。原字符串右对齐,前面填充0
返回指定长度的字符串
例子:
str = "this is string example from runoob....wow!!!"
print ("str.zfill : ",str.zfill(50))
输出:
str.zfill : 000000this is string example from runoob....wow!!!