python3 AttributeError: 'NoneType' object has no attribute 'split'


 1 from wsgiref.simple_server import make_server
 2  
 3 def RunServer(environ, start_response):
 4     start_response('200 ok',[('Content-Type','text/html')])
 5     return '<h1>Hello world</h1>'
 6 
 7 if __name__ == '__main__':
 8     httpd = make_server('127.0.0.1',9000,RunServer)
 9     print('servering HTTP on port 9000')
10     httpd.serve_forever()
Code

運行時報錯:

self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

 

解決辦法如下:

return ['<h1>Hello world</h1>'.encode('utf-8'),]

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM