问下这里为啥要写 d=dict(eval(item)),是什么意思,一直没想明白,麻烦帮忙看看
def search():
student_query=[]
while True:
id=''
name=''
if os.path.exists(filename):
mode=input('按照id查找输入1,按姓名查找输入2\n')
if mode=='1':
id=input('请输入id值:')
elif mode=='2':
name=input('请输入姓名:')
else:
print("您的输入有误")
search()
with open(filename,'r',encoding='utf-8') as rfile:
students=rfile.readlines()
for item in students:
d=dict(eval(item))
if id != '':
if d['id']==id:
student_query.append(d)
elif name != '':
if d['name']==name:
student_query.append(d)