title: Remove Whitespace: 'This is lazy' date: 2024-11-28
字符串最常用的方法
1 strip
y = "
This is lazy\t\n
"
print(y.strip())
2 lower upper
print("DrDre".lower())
print("attention".upper())
3 startswith endswith
print("smartphone".startswith("smart"))
print("smartphone".endswith("phone"))
4 find replace
print("another".find("other"))
print("cheat".replace("ch", "m"))
5 join
print(','.join(["F", "B", "I"]))
print(len("Rumpelstiltskin"))
print("ear" in "earth")