我尝试将numpy.ndarray
写入文件。
我用
unique1 = np.unique(df['search_term'])
unique1 = unique1.tolist()
然后尝试 1)
edf = pd.DataFrame()
edf['term'] = unique1
writer = pd.ExcelWriter(r'term.xlsx', engine='xlsxwriter')
edf.to_excel(writer)
writer.close()
和2)
thefile = codecs.open('domain.txt', 'w', encoding='utf-8')
for item in unique:
thefile.write("%s\n" % item)
但所有人都返回UnicodeDecodeError: 'utf8' codec can't decode byte 0xd7 in position 9: invalid continuation byte