Split a string by a delimiter in python

前端 未结 3 1432
名媛妹妹
名媛妹妹 2020-11-22 06:58

How to split this string where __ is the delimiter

MATCHES__STRING

To get an output of [\'MATCHES\', \'STRING\']?

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 07:38

    You can use the str.split function: string.split('__')

    >>> "MATCHES__STRING".split("__")
    ['MATCHES', 'STRING']
    

提交回复
热议问题