炫意html5
最早CSS3和HTML5移动技术网站之一

python 制作网页 遇到的问题

在使用python 制作网页时 遇到个这个问题
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xbf in position 0: invalid start byte

先看代码

import remi.gui as gui
from remi import start, App
class MyApp(App):
def __init__(self, *args):
super(MyApp, self).__init__(*args)
def main(self):
wid = gui.VBox(width=300, height=200, margin='0px auto')
self.lbl = gui.Label('Press the button', width='80%', height='50%')
self.lbl.style['margin'] = 'auto'
self.bt = gui.Button('Press me!', width=200, height=30)
self.bt.style['margin'] = 'auto 50px'
# setting the listener for the onclick event of the button
self.bt.onclick.do(self.on_button_pressed)
# appending a widget to another, the first argument is a string key
wid.append(self.lbl)
wid.append(self.bt)
# returning the root widget
return wid
# listener function
def on_button_pressed(self, widget):
self.lbl.set_text('A notification message should appear.')
self.bt.set_text('Hi!')
self.notification_message("Message title", "Hello world!", "")
if __name__ == "__main__":
# starts the webserver
# optional parameters
# start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1,
# start_browser=True)
start(MyApp, debug=True, address='0.0.0.0', port=0, )

这是报错

D:\Learn\Anaconda3\python.exe D:/Learn/PyCharm/(44)英语学习助手/Html/test2.py
Traceback (most recent call last):
File “D:/Learn/PyCharm/(44)英语学习助手/Html/test2.py”, line 38, in <module>
start(MyApp, debug=True, address=’0.0.0.0′, port=0, )
File “D:\Learn\Anaconda3\lib\site-packages\remi\server.py”, line 928, in start
s = Server(main_gui_class, start=True, **kwargs)
File “D:\Learn\Anaconda3\lib\site-packages\remi\server.py”, line 819, in init
self.start()
File “D:\Learn\Anaconda3\lib\site-packages\remi\server.py”, line 833, in start
self._sserver = ThreadedHTTPServer((self._address, self._sport), self._gui, self._auth,
File “D:\Learn\Anaconda3\lib\site-packages\remi\server.py”, line 765, in init
HTTPServer.init(self, server_address, RequestHandlerClass)
File “D:\Learn\Anaconda3\lib\socketserver.py”, line 452, in init
self.server_bind()
File “D:\Learn\Anaconda3\lib\http\server.py”, line 140, in server_bind
self.server_name = socket.getfqdn(host)
File “D:\Learn\Anaconda3\lib\socket.py”, line 756, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xbf in position 0: invalid start byte

进程已结束,退出代码为 1

这似乎是说我的编码格式有问题 但是我的编码格式是utf-8 的

请大佬帮忙看看是什么情况

回答

换一个python的版本试试 我将3.8的换成了3.5的 就好了

炫意HTML5 » python 制作网页 遇到的问题

Java基础教程Android基础教程