
能理解把字符串中大写字母变成小写,但是为什么要用ord和chr函数,那个不是ASCII值转换的时候才用吗?没整明白这之间有什么关系(゚o゚;

就是ascii转换啊,因为大写小写的ascii的差是相等的
def lower_self(s):
result = ""
for c in s:
if ord(c) >= 65 and ord(c) <= 90:
result += chr(ord(c) + 32)
else:
result += c
return result