所以有一个字符串foo = 'asdfasdfzxc<test>afx<one>'
如何获取bar = ['asdfasdfzxc','test','afx','one']
?
最佳答案
尝试,
import re
foo = 'asdfasdfzxc<test>afx<one>'
bar = re.split(r'[\<\>]',foo)[:-1]
bar.remove('afx')
bar
Out[89]:
['asdfasdfzxc', 'test', 'one']
关于python - 如何从预先分割的字符串中获取列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46923963/