Discuss / Python / 找不到原因,总是提示这个错误,不知道怎么改了。

找不到原因,总是提示这个错误,不知道怎么改了。

Topic source

吼kk

#1 Created at ... [Delete] [Delete and Lock User]

#use.WSGI.py

def application(environ, start_response):

start_response("200 OK", [("Content-Type", "text/html")])
body = "<h1>Hello {}</h1>".format(environ["PATH_INFO"][1:] or "web")
return [body.encode("utf-8")]

#server.py

from wsgiref.simple_server import make_server from use_WSGI import application

httpd = make_server("", 8000, application) print("serving http on prot 8000...") httpd.serve_forever()

错误显示: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte

远博老伯

#2 Created at ... [Delete] [Delete and Lock User]

我也是这个原因 而且learning.py那个文件启动也是报这个错 有人帮帮忙吗,搜不到解决方法

远博老伯

#3 Created at ... [Delete] [Delete and Lock User]

已解决,是因为计算机名为中文导致的,改成英文就可以了

吼kk

#4 Created at ... [Delete] [Delete and Lock User]
  • 你是说路径名不能有中文还是计算机用户名字不能是中文?

5zhouchuang

#5 Created at ... [Delete] [Delete and Lock User]

你的代码我直接copy,在我的电脑上是可以正常运行的,3楼说的就是你的电脑的计算机名设置成中文的意思吧,你可以试试把脚本放到其它的环境跑一下,或在虚拟机里面试试

南在南方Q

#6 Created at ... [Delete] [Delete and Lock User]

太棒了

hi_purple

#7 Created at ... [Delete] [Delete and Lock User]

能请问下是在哪找到解决方案的吗? 我也碰到了相应的问题,想看下排查的手段是啥 ^_^。

ywjco_567

#8 Created at ... [Delete] [Delete and Lock User]

#use.WSGI.py


from use_WSGI import application

from use_WSGI import application

低级的错误。


  • 1

Reply