用学号、姓名查询学生信息python
"""功能:按功能查询学生记录作者:日期:"""students = []f = open('学生.txt')for line in f:line = line.replace('\n', '')student = tuple(line.split(' '))students.append(student)id = input('请输入待查学生的学号:')found = Falsefor stud
·
"""
功能:按功能查询学生记录
作者:
日期:
"""
students = []
f = open('学生.txt')
for line in f:
line = line.replace('\n', '')
student = tuple(line.split(' '))
students.append(student)
id = input('请输入待查学生的学号:')
found = False
for student in students:
if (student[0] == id):
found = True
for i in range(len(student)):
print(student[i], end = ' ')
break
if not found:
print('学号为[{}]的学生没找到!'.format(id))
"""
功能:按功能查询学生记录
作者:
日期:
"""
students = []
f = open('学生.txt')
for line in f:
line = line.replace('\n', '')
student = tuple(line.split(' '))
students.append(student)
name = input('请输入待查学生的姓名:')
found = False
for student in students:
if (student[1] == name):
found = True
for i in range(len(student)):
print(student[i], end= ' ')
if not found:
print('姓名为[{}]的学生没找到!'.format(name))
更多推荐
已为社区贡献1条内容
所有评论(0)