大小写转换

编写程序,用户输入一个字符串,将其中小写字母全部转换成大写字母,把大写字母全部转换成小写字母,其他字符不变输出。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬

注:string.ascii_lowercase 可用于返回所有小写字母,string.ascii_uppercase 可用于返回所有大写字母

import string
str1 = input()
for i in str1:
    if i in string.ascii_lowercase:
        print(i.upper(),end="")
    elif i in string.ascii_uppercase:
        print(i.lower(),end="")
    else:
        print(i,end="")

 

posted @ 2020-04-03 19:26  L_Hjgg  阅读(1102)  评论(0编辑  收藏  举报