capitalize
对字符串的第一个字符大写
Return a capitalized version of S, i.e. make the first character have upper case and the rest lower case.
test = 'dabeam ' #在最前面添加空格 test = ' dabeam '
v = test.capitalize()
print(v)
print(test)
输出结果:
Dabeam #输出为原字符串 dabeam
dabeam
casefold
将字符串中大写变小写,可用于所有的语言
Return a version of S suitable for caseless comparisons.
test = ' DabeAm '
v = test.casefold()
print(v)
print(test)
结果:
dabeam
DabeAm
center
输出一个有具体长度的字符串,目标字符串在中间
Return S centered in a string of length width. Padding is done using the specified fill character (default is a space).
test = ' DabeAm '
v = test.center(20)
print(v)
print(test)
结果:
DabeAm
DabeAm