成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術文章
文章詳情頁

Python字符串轉大小寫問題

瀏覽:109日期: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 編程
相關文章: