leetcode709. 转换成小写字母 最秀狼人做法(比狠多一点)

实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串。

 

示例 1:

输入: "Hello"
输出: "hello"

示例 2:

输入: "here"
输出: "here"

示例 3:

输入: "LOVELY"
输出: "lovely"

一个一个的比着换,狠不狠。

class Solution:
    def toLowerCase(self, str: str) -> str:
        str=str.replace("A","a").replace("B","b").replace("C","c").replace("D","d").replace("E","e").replace("F","f").replace("G","g").replace("H","h").replace("I","i").replace("J","j").replace("K","k").replace("L","l").replace("M","m").replace("N","n").replace("O","o").replace("P","p").replace("Q","q").replace("R","r").replace("S","s").replace("T","t").replace("U","u").replace("V","v").replace("W","w").replace("X","x").replace("Y","y").replace("Z","z")
        return str

 

©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页