Separate lines and keep int python comma

I have the following line

c='a,b,c,"d,e",f,g' 

and i want to get

 b=['a','b','c','d,e','f','g'] 

So

 b[3]=='d,e' 

any ideas? The problem with c.split(',') is that it also breaks into 'd,e'

[I see the answer here for C ++, this of course did not help me]

Many thanks

+6
source share
1 answer

You can use the CSV module if c really should be lower ...

 import csv c = 'a,b,c,"d,e",f,g' print next(csv.reader([c])) # ['a', 'b', 'c', 'd,e', 'f', 'g'] 
+22
source

Source: https://habr.com/ru/post/926943/


All Articles