709. 转换成小写字母

 1 class Solution(object):
 2     def toLowerCase(self, str):
 3         """
 4         :type str: str
 5         :rtype: str
 6         """
 7         res = ""
 8         for i, ch in enumerate(str):
 9             if ord(ch) <= 90 and ord(ch) >= 65:
10                 res += chr(ord(ch) + 32)
11             else:
12                 res += ch
13         return res
14 
15     def toLowerCase2(self, str):
16         """
17         :type str: str
18         :rtype: str
19         """
20         return str.lower()
21 
22 
23 if __name__ == '__main__':
24     solution = Solution()
25     print(solution.toLowerCase("HellO"))
原文地址:https://www.cnblogs.com/panweiwei/p/12697773.html