如果我想拆分由分隔符分隔的单词列表,我可以使用
>>> 'abc,foo,bar'.split(',')
['abc', 'foo', 'bar']
Run Code Online (Sandbox Code Playgroud)
但是,如果我还想处理可以包含分隔符字符的带引号的字符串,如何轻松快速地做同样的事情?
In: 'abc,"a string, with a comma","another, one"'
Out: ['abc', 'a string, with a comma', 'another, one']
Run Code Online (Sandbox Code Playgroud)
python ×1