文章詳情頁
Python字符串轉大小寫問題
瀏覽:121日期: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()
上一條:python - 個人博客數據庫設計的問題下一條:
相關文章:
1. bootstrp是col-md-12列的,只有col-md-10有內容,可以讓沒有內容的不占據位置嗎;2. wordpress里,這樣的目錄列表是屬于小工具還是啥?3. 常量在外面不加引號會報錯。4. mysql federated引擎無法開啟5. 百度地圖 - Android app中準備接入地圖sdk,百度VS高德哪個好一點?6. 我的怎么不顯示啊,話說有沒有QQ群什么的7. sublime text3安裝package control失敗8. python 3.4 error: Microsoft Visual C++ 10.0 is required9. android - Genymotion 微信閃退 not find plugin.location_google.GoogleProxyUI10. MySQL 使用 group by 之后然后 IFNULL(COUNT(*),0) 為什么還是會獲得 null
排行榜
