('2017-03-13 11:50:09',271,131), ('2017-03-14 16:52:19',273,131), ('2017-03-13 11:50:19',271,126), import re f_path='d:/1/qian.txt' dict1={} with open(f_path) as files: for file in files: time_qian = re.findall(r"'([^']*)'", file)[0] class_id=re.findall(r',(\w+),',file)[0] student_id=re.findall(r'(\w+)\)',file)[0] dict1[student_id]={time_qian ,class_id} print(dict1)
'''
{'131': {'2017-030-14 16:52:19', '273'}, '126': {'2017-030-13 11:50:19', '271'}}
'''
标签:19,签到,qian,学生,re,file,2017,id,字典 From: https://www.cnblogs.com/haha1988/p/17550232.html