跳转至

🔥AI副业赚钱星球

点击下面图片查看

郭震AI

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")
京ICP备20031037号-1