分割:
不指定
s = "hello world"
parts = s.split()
print(parts) # 输出:['hello', 'world']
指定分隔符
result = "/".join(s.split("/")[:2])
s = "apple,banana,cherry"
parts = s.split(",")
print(parts) # 输出:['apple', 'banana', 'cherry']
指定最大分割次数:可以限制分割的次数。
s = "one:two:three:four"
parts = s.split(":", 2) # 只分割两次
print(parts) # 输出:['one', 'two', 'three:four']