(1)转字母

ch=input("请输入字母:")

if ch>'a' and ch<'z':

  print("大写:",ch.upper())

elif ch>='A' and ch<='Z':

 print("小写:",ch.lower())

else:

    print("输入错误")

 

#(2)字符串(全转)

ch=input("请输入字母:")

print(ch.swapcase())

#a小转大

ch=input("请输入字母:")

print(ch.swapcase())

#b大转小

ch=input("请输入字母:")

print(ch.swapcase())

#(3)开头首字母大写

ch=input("请输入字母:")

print(ch.capitalize())

#(4)标题样式

ch=input("请输入字母:")

print(ch.title())

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐