import re
text = """3843700 "4c4e276567929c747ab6709b" null "12345678” zzzzz"""#用户id,微信号,null,QQ号,没用的字符串
pattern = re.compile(r'(.*?) +(.*?) +null +(.*?) +(.*?).*', re.I) # re.I 表示忽略大小写
m = pattern.finditer(text)
a = ["用户id","微信号","QQ号"]
b = [m[0],m[1],m[2]]
c = dict(zip(a,b))
print(c)
import re
pattern1 = re.compile(r'"\w+"\tnull\t".+"\t\d+\t\d\t\d\t\d')
#print(pattern1.findall(user))
it = pattern1.finditer("2287345 \"4db7abcc6a238ed5d8e486d8\" null \"DJ Mike too the rescue!\" 1303971421 0 1 1 \"4bf58dd8d48988d1e5931735\" \"4c7c6b4fdbaa76b04e1c314b\" null \"\"The best teachers only come from Pen.\"\" 1303711907 0 1 1 ")
for march in it:
print(march.group()+'\n')
第二段存在匹配过长的问题