019、字符串 upper()、capitalize()、title() 区别
作者:互联网
字符串 upper()、capitalize()、title() 区别 见如下代码:
a = 'hello worlD, hello pyThon' print(a.title()) # 把每个单词的第一个字母变成大写,其他字母变小写 print(a.capitalize()) # 将字符串的第一个字母变成大写,其他字母变小写; print(a.upper()) # 所有都变成大写; print(a)
执行结果如下:
D:\SkyWorkSpace\WorkSpace\Pytest\Temp\day06\venv\Scripts\python.exe D:/SkyWorkSpace/WorkSpace/Pytest/Temp/day06/hh/test_02.py Hello World, Hello Python Hello world, hello python HELLO WORLD, HELLO PYTHON hello worlD, hello pyThon Process finished with exit code 0
标签:upper,title,Hello,print,019,capitalize,hello 来源: https://www.cnblogs.com/qq-2780619724/p/15073340.html