我正在读取一组文件到列表,然后使用Pickle.dump
将列表写到单个文件中。但是,某些无效字符会像\80]q\00(XK\00\00\00
一样被添加到新文件的开头。如何删除这些?
if(gyro):
lines = []
for fil in gyro:
file_name = os.path.join(file_path,fil)
file_data = open(file_name)
lines.extend(file_data.readlines())
file_data.close
os.remove(file_name)
uncompressed_filename = "raw_gyro.txt"
uncompressed_filename = os.path.join(file_path,uncompressed_filename)
with open(uncompressed_filename, "wb") as fp3:
print("Created",uncompressed_filename)
pickle.dump(lines, fp3)