想写一个对考生按照成绩进行排序的代码 但是在读取文件后报错 无法解决
f=open(r'/Users/86136/Desktop/JJ.txt',mode='w')
n=0;list1,list2,list3=[],[],[]
while 1:
a=input('please:')
f.write(a)
f.write('\n')
n+=1
if n>10 or a=='':
break
f.close()
f=open(r'/Users/86136/Desktop/JJ.txt',mode='r')
while 1:
c=f.readline()
if not c:
break
b=c.split()
e=b[0];f=b[1];g=b[2]
list1.append(e)
list2.append(f)
list3.append(g)
n=len(list3)
while 1:
for i in range(n):
if i!=n-1:
if list3[i]>list3[i+1]:
list3[i],list3[i+1]=list3[i+1],list3[i]
list2[i], list2[i+1]= list2[i+1], list2[i]
list1[i], list1[i+1]= list1[i+1], list1[i]
print(list3,list1,list2,n)
n=n-1
if n<=1:
break
f.close()
不应该啊,你加一行代码,看看打印的f是什么类型
f=open(r'/Users/86136/Desktop/JJ.txt',mode='r')
print(type(f))