发布时间:2022-11-12 19:00
转换代码如下:
import sys
sys.getdefaultencoding()
import pickle
import numpy as np
np.set_printoptions(threshold=1000000000000000)
path = 'F:/Python_File/beam/MCS_results_006.pkl'
file = open(path,'rb')
inf = pickle.load(file,encoding='iso-8859-1') #读取pkl文件的内容
print(inf)
#fr.close()
inf=str(inf)
obj_path = 'F:/Python_File/beam/MCS_results_006.txt'
ft = open(obj_path, 'w')
ft.write(inf)
ft.close()
如果转换结果中出现一行数据分成了两行的现象,如下:
只需在将样本数据写入pickle文件之前加上代码:
np.set_printoptions(linewidth=400) # print without newlines modified by Yue