string内置函数
title()
功能:得到“标题化”的字符串,每个单词的首字母大写,其余小写
str = “aaBB”
print(str.title())
center(with,fillchar(填充字符))
功能:返回一个指定宽度with的居中字符串,fillchar为填充字符
str = "aaBB"
print("*" + str.center(10,"^") + "*')
ljust(with,fillchar)
功能:返回一个指定宽度with的左对齐字符串
str = "aaBB"
print("*" + str.ljust(10,"^") + "*')
rjust((with,fillchar)
功能:返回一个指定宽度with的右对齐字符串
str = "aaBB"
print("*" + str.rjust(10,"^") + "*')
zfill()
str = "aaBB"
print("*" + str.zfill(10,"^") + "*')
count()
功能:返回str在string里面出现的次数
str1 = "aabb"
str2 = "aabb,aabb,aabb,aabbaabb,ss33,ffaa,ggaa,ggegwga"
print(str2.count(str))