用Python如何编写啊 真不会啊?

img


f = open('a.txt', 'r', encoding='utf-8')
d = f.read()
f.close()
code = input('输入学号')
s = True
for i in d.split('\n'):
    xuehao, name = i.split(' ')
    if code == xuehao:
        print(f'学号{xuehao}的姓名:{name}')
        s = False
if s:
    print('查无此人')

img

img

如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢