文章詳情頁
Python字符串轉大小寫問題
瀏覽:83日期:2022-06-27 16:02:46
問題描述
str.lower() 字符串全小寫。str.upper() 字符串全大寫。
>>> str = ’my world, MY PYTHON’>>> str.lower()’my world, my python’>>> str.upper()’MY WORLD, MY PYTHON’
如何才能使字符串每個單詞首字母都大寫? 使 str = ’My World, My Python’
問題解答
回答1:參考文章:Python字符串操作相關問題
字符串大小寫轉換str.lower() 字符串全小寫。str.upper() 字符串全大寫。str.capitalize() 字符串首字母大寫。str.title() 字符串每個單詞首字母都大寫。
>>> 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’回答2:
str.title()
相關文章:
排行榜
