# 封装数据,写入文件
comment_dir = {'user': users, 'score': scores, 'time': times, 'comment': comments}
comment_df = pd.DataFrame(comment_dir)
comment_df.to_csv('./tables/taptap_comments.csv')
comment_df['comment'].to_csv('./tables/comments.csv', index=False)
print(comment_df)
疯狂报错
发生异常: FileNotFoundError
[Errno 2] No such file or directory: './tables/taptap_comments.csv'
File "C:\Users\Aki\Desktop\python\函数基础\BS\taptapciyun.py", line 48, in crawl_comments
comment_df.to_csv('./tables/taptap_comments.csv')
File "C:\Users\Aki\Desktop\python\函数基础\BS\taptapciyun.py", line 103, in <module>
blacksurvival.crawl_comments()
改成绝对路径也是依然报错。
comment_dir = {'user': users, 'score': scores, 'time': times, 'comment': comments}
comment_df = pd.DataFrame(comment_dir)
comment_df.to_csv('C:\\Users\Aki\Desktop\python\函数基础\BS\taptap_comments.csv')
comment_df['comment'].to_csv('./tables/comments.csv', index=False)
print(comment_df)
报错如下:
发生异常: OSError
[Errno 22] Invalid argument: 'C:\\Users\\Aki\\Desktop\\python\\函数基础\\BS\taptap_comments.csv'
File "C:\Users\Aki\Desktop\python\函数基础\BS\taptapciyun.py", line 48, in crawl_comments
comment_df.to_csv('C:\\Users\Aki\Desktop\python\函数基础\BS\taptap_comments.csv')
File "C:\Users\Aki\Desktop\python\函数基础\BS\taptapciyun.py", line 103, in <module>
blacksurvival.crawl_comments()