利用python进行数字大小排序

利用python进行数字大小排序

文件这样子:

代码:
fl = open('luciatest1.txt')
l = []
sortedl = []
for lines in fl.readlines():
lines = lines.replace("\n", "")
l.append(lines)
print('\n', 'the original file is:', l)

sortedl = sorted(l)
print('\n', 'the sorted file is:', sortedl)

运行结果:
温馨提示:答案为网友推荐,仅供参考
相似回答