帖子发不出去了!问题放在二楼!
麻烦各位大神看看哪里错了
address=list()
print("1.显示所有信息")
print("2.追加信息")
print("3.删除信息")
print("4.退出")
number=['1','2','3','4']
while True:
n=(input('请输入数字1-4选择功能:'))
if n in number:
break
else:
print('输入错误,请重新输入!')
continue
while True:
if n=='1':
f=open('address.txt')
f.seek(0)
for line in f:
print(line,end='')
f.close()
elif n=='2':
a=str(input('请输入学生信息并用逗号隔开:'))
b=('\n')
f=open('address.txt','a')
f.write(b)
f.write(a)
f.close()
f=open('address.txt')
f.seek(0)
for line in f:
print(line,end='\n')
f.close()
elif n=='3':
f=open('address.txt')
student=list(f)
f.close()
f=open('address.txt','w')
d=input('请输入要删除的学生学号:')
for s in student:
if s[:1]==d:
print('已删除学号为'd'的学生信息')
else:
f.write(s)
f.close()
else:
break
|