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

来源:互联网 发布:开淘宝店挣钱吗 编辑:程序博客网 时间:2024/06/06 19:51

当我们编写wsgi时候报错

错误内容

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

出错代码

def application(environ,start_response):    status = '200 OK'    response_headers = [('Content-type', 'text/plain')]    start_response(status, response_headers)    return [u"hello"]from wsgiref.simple_server import make_server#导入系统的wsgi包from webapp import application#引入服务器的代码server =make_server('', 8080, application)#实例化一个监听8080端口的服务器server.serve_forever()#开始监听http请求

解决方案

给返回内容加上.encode(‘utf8’)

return [u"hello".encode('utf8')]
阅读全文
0 0
原创粉丝点击