实现说明
顶层就这几处状态:codes、toggled、raw、normal。
使用要点
- 跑完文件,输出里会留下标记——
Spring Boot、changed:。
常见问题
除了语言工具链还要下载什么吗?
除了这个语言的工具链,什么都不用再下载。 文件用顶层绑定保存自己的状态:codes、toggled、raw。
代码示例
codes = ["HTTP", "12ab", "1234", ""]
print([c.isupper() for c in codes]) # True False False False
# 纯数字与空串不满足任何大小写判定,全部 False
print([c.islower() for c in codes])
# istitle 要求每个单词首字母大写
print("Spring Boot".istitle(), "Spring boot".istitle())
# swapcase 交换大小写并往返一致
toggled = "Proxy-Auth".swapcase()
print(toggled, toggled.swapcase())
# 宽松化输入前先看原始形态再决定是否归一
raw = "MiXeD CaSe"
normal = raw.lower()
print("changed:", raw != normal, normal)