具体代码,是啥,感觉老不对,用Python的,能够分享一下吗?最好有解析,来自初学者的目光
rf=open('data.txt')
#读取文件所有行
lines=rf.readlines()
rf.close()
a=[]
#循环每一行
for line in lines:
#根据具体数据格式处理,这里是每一行都是一个数的处理
#取出数字的字符串转为int,并加入列表a里
a.append(int(line.strip()))
#a排序
a.sort()
print(a)