昵称

nichen
514 号测试 成员, 2018-12-01 03:11:09 加入
1.2k
个人主页浏览
  • Python13 期字符串大考核!!!

    2020-07-24 10:55
    a = "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))