str.lower()
字符串全小寫。str.upper()
字符串全大寫。
>>> str = 'my world, MY PYTHON'
>>> str.lower()
'my world, my python'
>>> str.upper()
'MY WORLD, MY PYTHON'
如何才能使字符串每個(gè)單詞首字母都大寫
? 使 str = 'My World, My Python
'
歡迎選擇我的課程,讓我們一起見證您的進(jìn)步~~
參考文章:Python字符串操作相關(guān)問題
str.lower()
字符串全小寫。str.upper()
字符串全大寫。str.capitalize()
字符串首字母大寫。str.title()
字符串每個(gè)單詞首字母都大寫。
>>> str = 'my world, MY PYTHON'
>>> str.lower()
'my world, my python'
>>> str.upper()
'MY WORLD, MY PYTHON'
>>> str.capitalize()
'My world, my python'
>>> str.title()
'My World, My Python'