import re
subject = '''
aaa,b b,"""c"" cc"
1,,"333, three,
still more threes"
'''
result = ""
reobj = re.compile(r'''(,|\r?\n|^)([^",\r\n]+|"(?:[^"]|"")*")?''')
for matchobj in reobj.finditer(subject):
if matchobj.group(1) == ",":
if matchobj.group(2) is None:
result += "\t" + ""
else:
result += "\t" + matchobj.group(2)
else:
result += matchobj.group()
print result
aaa b b """c"" cc" 《===双引号没有去掉??有没有高人可以指点一下
1 "333, three,
still more threes" 《====这里没有对齐??