文章詳情頁
Python字符串轉大小寫問題
瀏覽:104日期: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()
相關文章:
1. 數據庫 - MySQL 單表500W+數據,查詢超時,如何優化呢?2. javascript - 百度echarts series數據更新問題3. 求大神幫我看看是哪里寫錯了 感謝細心解答4. MySQL客戶端吃掉了SQL注解?5. mac 安裝 python_MySQLdb6. javascript - 圖片能在網站顯示,但控制臺仍舊報錯403 (Forbidden)7. php自學從哪里開始?8. mysql - AttributeError: ’module’ object has no attribute ’MatchType’9. python小白的基礎問題 關于while循環的嵌套10. phpstady在win10上運行
排行榜
