典型的ConfigParser生成的文件如下所示:
[Section]
bar=foo
[Section 2]
bar2= baz
Run Code Online (Sandbox Code Playgroud)
现在,有没有办法索引列表,例如:
[Section 3]
barList={
item1,
item2
}
Run Code Online (Sandbox Code Playgroud)
我需要能够得到一个字符串:
'''foo, bar, "one, two", three four'''
Run Code Online (Sandbox Code Playgroud)
成:
['foo', 'bar', 'one, two', 'three four']
Run Code Online (Sandbox Code Playgroud)
我有一种感觉(来自#python的提示)该解决方案将涉及shlex模块.
我有这个字符串'id,obj1,"string, etc",obj2',现在我需要把它分成这样的字典:
{
1 = 'id',
2 = 'obj1',
3 = 'string, etc',
4 = 'obj2'
}
Run Code Online (Sandbox Code Playgroud)
我一直在玩正则表达式,试图划分字符串但没有成功.任何帮助表示赞赏