如图的txt文件,把它读成数组然后也是用这个我复制来的代码排序,它能运行,但是输出的结果并没有排好序啊喂,请问这个应该怎么做呢
import pandas as pd
import numpy as np
import codecs
filepath = r'C:\Users\zhf\Desktop\华为杯\原型系统V10\中间文件\数据集202006\xxxxx209\无tu的数据集\_xxxxx209_固态坏了_.txt'
file = codecs.open(filepath, "r", "utf-8")
notulist = [line.strip() for line in file] # 多使用列表推导式
one_str = ""
for eve in notulist:
one_str = one_str + eve + " "
print(notulist)
readlines读取到的是一行一行的值,你需要把data1分割为一个一个的值,而不是一行一行的。然后在排序