ABC*_*BCD 1 python split python-3.x
我有一个字符串 -
"one:two:three:four:five:six:seven:eight"
.
现在我想用 ':' 分割这个字符串,但直到前 3 次出现 ':'。
预期输出 -
['one','two','three','four:five:six:seven:eight']
.
我怎么能这样做?
split
采用maxsplit
除分隔符以外的参数,它的作用正是:
s.split(':',3)
# ['one', 'two', 'three', 'four:five:six:seven:eight']
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
61 次 |
最近记录: |