-
Python13 期字符串大考核!!!
2020-07-24 10:55a = "sdSdsfdAdsdsdfsfdsdASDSDFDSFa" # 大小写互换 new_a = a.swapcase() # 镜像字符串 str_image = ""# 镜像后的字符串 str_1 = "abcdefghijklmnopqrstuvwxyz" str_2 = str_1[::-1] # 小写字母对应镜像字符串 for i in new_a: if i.islower(): str_image += str_2[str_1.find(i)] else: str_image += str_2[str_1.find(i.lower())].upper() print("""大小写互换后:{} 镜像字符串为:{}""".format(new_a,str_image))