主页
Python
Python String split() 方法
demo_ref_string_split4
运行 ❯
×
更改方向
保存代码
更改主题
txt = "apple#banana#cherry#orange" # setting the maxsplit parameter to 1, will return a list with 2 elements! x = txt.split("#", 1) print(x)
['apple', 'banana#cherry#orange']