(str.rstrip())
分隔字符串
str = ' 1 , 2 , 3 , 4 , 5 , '
# 默认使用空格分隔
print (str.split()) # ['1', ',', '2',...',', '3', ',', '4', ',', '5', ',']
# 指定使用空格进行分隔,首尾如果有空格,则会出现在结果中
print (str.split(' ')) # ['', '1',...,第一个为分隔符左边的子串,第二个为分隔符本身,第三个为分隔符右边的子串。...string
格式化输出
居中填充
# str.center(width[, fillchar])
# 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串。...默认填充字符为空格
str = "this is string example....wow!!!"