Discuss / Python / 求助,调用mark_server()出现UnicodeDecodeError

求助,调用mark_server()出现UnicodeDecodeError

Topic source

Mahogany3

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

代码是copy上面的,在师兄电脑可以运行,但我的命令行就会出现Error。是和socket模块被的gethostbyaddr()有关。

F:\HelloWorld\Python\.vscode\廖雪峰>python server.py
Traceback (most recent call last):
  File "server.py", line 8, in <module>
    httpd = make_server('', 8000, application)
  File "C:\Users\fangz\AppData\Local\Programs\Python\Python38\lib\wsgiref\simple_server.py", line 154, in make_server
    server = server_class((host, port), handler_class)
  File "C:\Users\fangz\AppData\Local\Programs\Python\Python38\lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "C:\Users\fangz\AppData\Local\Programs\Python\Python38\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Users\fangz\AppData\Local\Programs\Python\Python38\lib\http\server.py", line 139, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Users\fangz\AppData\Local\Programs\Python\Python38\lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 2: invalid start byte

Mahogany3

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

破案了,去设置关于里面改主机名称,我用了中文的引号。


  • 1

Reply