前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python启动WSGI,make_server报错

Python启动WSGI,make_server报错

作者头像
用户2475223
发布2019-12-17 15:55:41
1.1K0
发布2019-12-17 15:55:41
举报
文章被收录于专栏:codersamcodersam

今天写了一个简单的python web server,启动后访问浏览器报了一个错误,如下:

代码语言:javascript
复制
Serving HTTP on port 8088...
127.0.0.1 - - [29/May/2019 16:08:29] "GET / HTTP/1.1" 200 0
Traceback (most recent call last):
File "D:\Python\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "D:\Python\lib\wsgiref\handlers.py", line 181, in finish_response
self.write(data)
File "D:\Python\lib\wsgiref\handlers.py", line 267, in write
"write() argument must be a bytes instance"
AssertionError: write() argument must be a bytes instance

根据报错信息提示最终可得知write()接收的参数不是一个bytes类型。 最终定位报错的位置在handlers.py finish_response() 这个函数中self.write(data),在self.write(data)上添加代码data=data.encode(),重启服务即可

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年5月29日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档