Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下字符串
c='a,b,c,"d,e",f,g'
我想得到
b=['a','b','c','d,e','f','g']
所以
b[3]=='d,e'
有任何想法吗?问题c.split(',')是它也会分裂'd,e'
c.split(',')
'd,e'
[我在这里看到了 C++ 的答案,这当然对我没有帮助]
非常感谢
c如果确实应该是以下内容,您可以使用 CSV 模块...
c
import csv c = 'a,b,c,"d,e",f,g' print next(csv.reader([c])) # ['a', 'b', 'c', 'd,e', 'f', 'g']