leetcode 转换成小写字母 Posted on 2021-12-13 In 算法 Views: Symbols count in article: 606 Reading time ≈ 1 mins. 709. 转换成小写字母给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。 示例 1: 12输入:s = "Hello"输出:"hello" 示例 2: 12输入:s = "here"输出:"here" 示例 3: 12输入:s = "LOVELY"输出:"lovely" 提示: 1 <= s.length <= 100 s 由 ASCII 字符集中的可打印字符组成 方法一: 1234567class Solution(object): def toLowerCase(self, s): """ :type s: str :rtype: str """ return s.lower() 方法二: 1234567891011121314class Solution(object): def toLowerCase(self, s): """ :type s: str :rtype: str """ res = '' for i in s: if ord(i) >= 65 and ord(i) <= 90: i = chr(ord(i) + 32) res += ''.join(i) else: res += i return res