709.转换成小写字母
class Solution:
def toLowerCase(self, s: str) -> str:
res = []
for c in s:
asc = ord(c) #c的ascii码
if asc >= 65 and asc <= 90: #说明是大写字母
lower = chr(asc + 32) #转小写
res.append(lower)
else:
res.append(c)
return ''.join(res)最后更新于