windows Python3报错 ValueError: embedded null byte

徘徊边缘 提交于 2019-12-23 01:47:32

调用爬取推特的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')

参考:

https://www.cnblogs.com/whitemouseV2-0/p/10170373.html

https://stackoverflow.com/a/42869865/9917670

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!