print str.capitalize() 结果:Mars is very slim and clever! 4.标题首字母大写:title() 用法:str='mARS iS slim and cLEver!' print str.title() 结果:Mars Is Slim And Clever! 判断...
print"okey as an identifier"8)String的内建方法string.capitalize()大写字符串的第一个字母string.center(width)字符串以给定宽度显示,如长度不足,两边补充空格string.count(str,beg=0,end=len(string))计算str...
print"okey as an identifier"8)String的内建方法string.capitalize()大写字符串的第一个字母string.center(width)字符串以给定宽度显示,如长度不足,两边补充空格string.count(str,beg=0,end=len(string))计算str...
a.replace('word','python') 4.2.2.Convert str to bytes in python gt;gt;gt;b=str.encode(y) gt;gt;gt;type(b)>gt;gt;b b’Hello World!To alter from bytes to str,capitalize on bytes.decode(). gt...
capitalize()将字符串第一个字符转换成大写。示例&xff1a;str1&61;39;Hello world Python!39;print(str1.capitalize())#Hello world python!注&xff1a;capitalize()函数转换后&xff0c;只将字符串第一个字符大写&xff0c;...
print("the first sentence.the second sentence.".capitalize()) 结果 The first sentence.the second sentence. TOP↑str.title()– 返回每个词首字母大写的字符串 代码 print("this is a title".title()) 结果 ...