学生签到字典

('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'}}
'''

 

posted @ 2023-07-13 13:38  胖豆芽  阅读(10)  评论(0)    收藏  举报