Python 正则表达式改变csv文件的分隔符

来源:互联网 发布:德州软件开发 编辑:程序博客网 时间:2024/04/30 13:26
import resubject = '''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"          《====这里没有对齐??
0 0
原创粉丝点击