Python 3 教程
以下代碼演示了如何將字符串轉換為大寫字母,或者將字符串轉為小寫字母等:
# Filename : test.py # author by : str = "" print(str.upper()) # 把所有字符中的小寫字母轉換成大寫字母 print(str.lower()) # 把所有字符中的大寫字母轉換成小寫字母 print(str.capitalize()) # 把第一個字母轉化為大寫字母,其余小寫 print(str.title()) # 把每個單詞的第一個字母轉化為大寫,其余小寫
執(zhí)行以上代碼輸出結果為:
WWW.JSON.COM m.9t9t.com.cn Www.Runoob.Com其他擴展