leetcode - 709 - 转换成小写字母

class Solution:
    def toLowerCase(self, str):
        """
        :type str: str
        :rtype: str
        """
        list=[]
        for i in range(len(str)):
            if "A" <= str[i] <= "Z":
                a=chr(ord(str[i]) + 32)
                list.append(a)
            else:
                list.append(str[i])
                
        return "".join(list)
            

猜你喜欢

转载自blog.csdn.net/hustwayne/article/details/83544698