调用爬取推特的twint库时候代码报错:
Traceback (most recent call last):
File "D:/pycharm project/twint/wangjinyu.py", line 10, in <module>
twint.run.Search(c)
File "D:\pycharm project\twint\twint\run.py", line 288, in Search
run(config, callback)
File "D:\pycharm project\twint\twint\run.py", line 209, in run
get_event_loop().run_until_complete(Twint(config).main(callback))
File "C:\Program Files\Python36\lib\asyncio\base_events.py", line 484, in run_until_complete
return future.result()
File "D:\pycharm project\twint\twint\run.py", line 150, in main
await task
File "D:\pycharm project\twint\twint\run.py", line 194, in run
await self.tweets()
File "D:\pycharm project\twint\twint\run.py", line 141, in tweets
await output.Tweets(tweet, self.config, self.conn)
File "D:\pycharm project\twint\twint\output.py", line 142, in Tweets
await checkData(tweets, config, conn)
File "D:\pycharm project\twint\twint\output.py", line 100, in checkData
tweet = Tweet(tweet, config)
File "D:\pycharm project\twint\twint\tweet.py", line 90, in Tweet
t.timezone = strftime("%Z", localtime())
ValueError: embedded null byte
主要是strftime方法报错,查了一下,在报错文件上方加两行代码就行了,原理未知。
import locale
locale.setlocale(locale.LC_ALL, 'en')
参考:
来源:CSDN
作者:wangjinyu124419
链接:https://blog.csdn.net/u011519550/article/details/103654658