Split a string only by first space in python

后端 未结 3 933
Happy的楠姐
Happy的楠姐 2020-11-30 07:23

I have string for example: \"238 NEO Sports\". I want to split this string only at the first space. The output should be [\"238\",\"NEO S

3条回答
  •  一生所求
    2020-11-30 07:43

    RTFM: str.split(sep=None, maxsplit=-1)

    >>> "238 NEO Sports".split(None, 1)
    ['238', 'NEO Sports']
    

提交回复
热议问题