How can i parse a comma delimited string into a list (caveat)?

后端 未结 6 1036
心在旅途
心在旅途 2020-12-05 14:11

I need to be able to take a string like:

\'\'\'foo, bar, \"one, two\", three four\'\'\'

into:

[\'foo\', \'bar\', \'one, two         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-05 14:45

    I'd say a regular expression would be what you're looking for here, though I'm not terribly familiar with Python's Regex engine.

    Assuming you use lazy matches, you can get a set of matches on a string which you can put into your array.

提交回复
热议问题