python3的相关模块都已安装,相关python代码如下:
# -*- coding: utf-8 -*-
from bottle import Bottle, run
app=Bottle()
@app.route('/hello')
def hello():
return '<strong>Hello world!</strong>'
run(app,host='localhost',port=81)
以上代码运行正确,但是我想在局域网下访问,把host改为局域网ip192.168.1.1后运行结果如下:
Bottle v0.12.8 server starting up (using WSGIRefServer())...
Listening on http://192.168.1.1:81/
Hit Ctrl-C to quit.
Traceback (most recent call last):
File "bottle_test.py", line 10, in <module>
run(app,host='192.168.1.1',port=81)
File "/usr/lib/python3.4/bottle.py", line 3117, in run
server.run(app)
File "/usr/lib/python3.4/bottle.py", line 2771, in run
srv = make_server(self.host, self.port, app, server_cls, handler_cls)
File "/usr/lib/python3.4/wsgiref/simple_server.py", line 153, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.4/socketserver.py", line 430, in __init__
self.server_bind()
File "/usr/lib/python3.4/wsgiref/simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.4/http/server.py", line 135, in server_bind
self.server_name = socket.getfqdn(host)
File "/usr/lib/python3.4/socket.py", line 463, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte
我怀疑是编码问题,但是确认python中sys编码为utf-8,该py文件编码也是utf-8。求助!