1、字符串首字母大写
i = "shulei_xiaoxin" S = i.capitalize() print(S)
Shulei_xiaoxin
2、字符串全部大写或小写
i = "shuLEI_XIAOxin" S = i.upper() S1 = i.lower() print(S) print(S1)
SHULEI_XIAOXIN
shulei_xiaoxin
3、不区分大小写验证码
i = "shuLEI_XIAOxin" VER_CODE = input("请输入验证码,不区分大小写:") if i.upper() == VER_CODE.upper(): print("验证成功,欢迎登录~~~") else: print("验证不成功,欢迎下次登录~~")
4、大小写反转
i = "shuLEI_XIAOxin" S = i.swapcase() print(S)
SHUlei_xiaoXIN
5、首字符及特殊字符、数据后的字符大写
i = "shuLEI**_XIAO11234xi3n" S = i.title() print(S)
Shulei**_Xiao11234Xi3N
标签:upper,Python,XIAOxin,print,shuLEI,大小写,xiaoxin,字符串,方法 From: https://www.cnblogs.com/leishu/p/16801499.html