代码是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
破案了,去设置关于里面改主机名称,我用了中文的引号。
Sign in to make a reply
Mahogany3
代码是copy上面的,在师兄电脑可以运行,但我的命令行就会出现Error。是和socket模块被的gethostbyaddr()有关。