在python中通过分隔符分割字符串 [英] Split a string by a delimiter in python
本文介绍了在python中通过分隔符分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何分割这个字符串,其中__
是分隔符
MATCHES__STRING
要获得 ['MATCHES', 'STRING']
的输出?
解决方案
您可以使用 str.split
方法:string.split('__')
How to split this string where __
is the delimiter
MATCHES__STRING
To get an output of ['MATCHES', 'STRING']
?
解决方案
You can use the str.split
method: string.split('__')
>>> "MATCHES__STRING".split("__")
['MATCHES', 'STRING']
这篇关于在python中通过分隔符分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文