[python]力扣709. 轉換成小寫字母

709. 轉換成小寫字母
“”"
實現函數 toLowerCase(),該函數接收一個字符串參數 str,並將該字符串中的大寫字母轉換成小寫字母,之後返回新的字符串。
示例 1:
輸入: “Hello”
輸出: “hello”
示例 2:
輸入: “here”
輸出: “here”
示例 3:
輸入: “LOVELY”
輸出: “lovely”
“”"

def toLowerCase(str):
    return str.lower()

str = "LOVELY"
print(toLowerCase(str))

彙總總結:
python字符串大小寫轉換

str = "www.runoob.com"
print(str.upper())  # 把所有小寫轉成大寫
print(str.lower())  #把所有大寫轉成小寫
print(str.capitalize())  # 把第一個字母轉成大寫,其餘小寫
print(str.title())  #把每個單詞的第一個字母轉成大寫,其餘小寫

執行以上代碼輸出結果爲:
WWW.RUOOB.COM
www.runoob.com
Www.runoob.com
Www.Runoob.Com

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章