Python 中pandas读取文件Initializing from file failed

代码:

pandas读取文件报如下的错误:

OSError: Initializing from file failed

原因:

当你用pandas读取文件报这种错误时,一般是因为你的文件名中带有中文

修改:

f = open('./搜狗新闻语料/val.txt','r', encoding='UTF-8')
df_news=pd.read_table(f,names=['category','theme','URL','content'],encoding='UTF-8')
df_news=df_news.dropna()
df_news.head()

猜你喜欢

转载自blog.csdn.net/visoprkx/article/details/85914650