Here's the code
import pandas as pd
error_code_link_lst = []
error_code_link_lst.append('twdJK7dzQR_x298_x298_x49147_x')
error_code_link_lst.append('1665207170810_x828_x1470_x745770_x.jpg') # _x1470_ ᑰ
error_code_link_lst.append('h4fdn32sjG_x593_x593_x199560_x')
error_code_link_lst.append('xEQpZ7JjkZ_x288_x288_x3108_x') # _x3108_ ㄈ
error_code_link_lst.append('SGkZYZKCRR_x298_x298_x49147_x')
df = pd.DataFrame()
df['link'] = [i for i in error_code_link_lst]
for i in df['link']:
print(i)
df.to_excel('error.xlsx', i开发者_运维知识库ndex=None)
Output in terminal is right:
twdJK7dzQR_x298_x298_x49147_x
1665207170810_x828_x1470_x745770_x.jpg
h4fdn32sjG_x593_x593_x199560_x
xEQpZ7JjkZ_x288_x288_x3108_x
SGkZYZKCRR_x298_x298_x49147_x
But in the xlsx
file, it looks like in a wrong encoding
link |
---|
twdJK7dzQR_x298_x298_x49147_x |
1665207170810_x828ᑰx745770_x.jpg |
h4fdn32sjG_x593_x593_x199560_x |
xEQpZ7JjkZ_x288_x288ㄈx |
SGkZYZKCRR_x298_x298_x49147_x |
It seems like _x1470_
-> ᑰ
and _x3108_
-> ㄈ
.
I try to use
df.to_excel('error.xlsx', index=None, encoding='utf-8')
, but it not works as well.I wonder why and how can I get the right data. Thanks!
Try specifying encoding='utf8'
as parameter in to_excel function.
Excel screenshot
精彩评论