已解决AttributeError: ‘NoneType‘ object has no attribute ‘split‘ 报错处理

古城微笑少年丶 2023-09-26 19:29 246阅读 0赞

已解决AttributeError: ‘NoneType’ object has no attribute ‘split’ 报错处理

在这里插入图片描述

文章目录

    • 报错问题
    • 解决方法
    • 声明

报错问题

粉丝群里面的一个小伙伴敲代码时发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错信息如下:

  1. [29/Apr/2019 15:12:02] "GET / HTTP/1.1" 200 6992
  2. [29/Apr/2019 15:12:11] "GET /login/weibo/ HTTP/1.1" 302 0
  3. [29/Apr/2019 15:12:13] "GET /complete/weibo/?state=cpNja8cxhyV9GPSKvjVfWnwogNskNjob&code=ba1e4f6fd32f32d0b57094eecd0e7d1b HTTP/1.1" 302 0
  4. Traceback (most recent call last):
  5. File "C:\Python36\lib\wsgiref\handlers.py", line 138, in run
  6. self.finish_response()
  7. File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
  8. self.write(data)
  9. File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
  10. self.send_headers()
  11. File "C:\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
  12. self._write(bytes(self.headers))
  13. File "C:\Python36\lib\wsgiref\headers.py", line 142, in __bytes__
  14. return str(self).encode('iso-8859-1')
  15. UnicodeEncodeError: 'latin-1' codec can't encode characters in position 251-253: ordinal not in range(256)
  16. [29/Apr/2019 15:12:13] "GET /complete/weibo/?state=cpNja8cxhyV9GPSKvjVfWnwogNskNjob&code=ba1e4f6fd32f32d0b57094eecd0e7d1b HTTP/1.1" 500 59
  17. ----------------------------------------
  18. Exception happened during processing of request from ('127.0.0.1', 11977)
  19. Traceback (most recent call last):
  20. File "C:\Python36\lib\wsgiref\handlers.py", line 138, in run
  21. self.finish_response()
  22. File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
  23. self.write(data)
  24. File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
  25. self.send_headers()
  26. File "C:\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
  27. self._write(bytes(self.headers))
  28. File "C:\Python36\lib\wsgiref\headers.py", line 142, in __bytes__
  29. return str(self).encode('iso-8859-1')
  30. UnicodeEncodeError: 'latin-1' codec can't encode characters in position 251-253: ordinal not in range(256)
  31. During handling of the above exception, another exception occurred:
  32. Traceback (most recent call last):
  33. File "C:\Python36\lib\wsgiref\handlers.py", line 141, in run
  34. self.handle_error()
  35. File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line 88, in handle_error
  36. super(ServerHandler, self).handle_error()
  37. File "C:\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
  38. self.finish_response()
  39. File "C:\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
  40. self.write(data)
  41. File "C:\Python36\lib\wsgiref\handlers.py", line 274, in write
  42. self.send_headers()
  43. File "C:\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
  44. if not self.origin_server or self.client_is_modern():
  45. File "C:\Python36\lib\wsgiref\handlers.py", line 344, in client_is_modern
  46. return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
  47. TypeError: 'NoneType' object is not subscriptable
  48. During handling of the above exception, another exception occurred:
  49. Traceback (most recent call last):
  50. File "C:\Python36\lib\socketserver.py", line 639, in process_request_thread
  51. self.finish_request(request, client_address)
  52. File "C:\Python36\lib\socketserver.py", line 361, in finish_request
  53. self.RequestHandlerClass(request, client_address, self)
  54. File "C:\Python36\lib\socketserver.py", line 696, in __init__
  55. self.handle()
  56. File "C:\Python36\lib\site-packages\django\core\servers\basehttp.py", line 155, in handle
  57. handler.run(self.server.get_app())
  58. File "C:\Python36\lib\wsgiref\handlers.py", line 144, in run
  59. self.close()
  60. File "C:\Python36\lib\wsgiref\simple_server.py", line 35, in close
  61. self.status.split(' ',1)[0], self.bytes_sent
  62. AttributeError: 'NoneType' object has no attribute 'split'
  63. ----------------------------------------

在这里插入图片描述

解决方法

解决方法如下

在这里插入图片描述
在这里插入图片描述

声明

解决方法借鉴于网络,如有侵权联系我删除

发表评论

表情:
评论列表 (有 0 条评论,246人围观)

还没有评论,来说两句吧...

相关阅读