标签:ora nbsp tle mil ali bsp font span lin
全字符
str.upper()
eg,
s = ‘ash‘
s.upper()
print(s) #ash
print(s.upper()) #ASH
str.lower()
仅首字母
全串首字母大写
str.capitalize()
一般情况
首字母若为空/数字
eg,
s = ‘a, b‘
s2 = ‘ a, b‘
s3 = ‘1, a, b‘
print(s.capitalize()) #A, b
print(s2.capitalize()) # [_]a, b
print(s3.capitalize()) #1, a, b
字符串中单词的首字母大写
str.title()
eg,
s = ‘ash, ruby‘
print(s.title()) #Ash, Ruby
标签:ora nbsp tle mil ali bsp font span lin
原文地址:https://www.cnblogs.com/norasgao/p/10545010.html