我想知道是否有人可以帮我弄清楚为什么我一直收到错误AssertionError:标题名称/值必须是str类型(得到b'Content-type') 127.0.0.1 - - [26 / Mar / 2015 20:50:52]“GET /favicon.ico HTTP / 1.1”500 59.代码来自Manning出版的“The Quick Python Book”。
from wsgiref.simple_server import make_server
def message_wall_app(environ, start_response):
status = b'200 OK' # HTTP Status
headers = [(b'Content-type', b'text/html; charset=utf-8')]
start_response(status, headers)
# The returned object is going to be printed
return ["<h1>Message Wall</h1>"]
httpd = make_server('', 8000, message_wall_app)
print("Serving on port 8000...")
# Serve until process is killed
httpd.serve_forever()