咸蛋超人 咸蛋超人 - 1 year ago 349
Python Question

flask UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte

I'm learning the flask module
I copy the code but it didn't work and give my the UnicodeDecodeError
here is the code and error

Thanks for your help

Answer Source

As the traceback point out, your computer's hostname has non-ASCII character. As this document said, you can use this way to get your hostname:

$ python
>>> from socket import *
>>> getnameinfo(("127.0.0.1", 0), 0)
('user-greyli', '0')  # here the 'user-greyli' is hostname

In windows system, the hostname was same as computer's name. So, you need to rename your computer's name.

How to do it? Just check this page. Besides, as a bonus, I capture a picture in Chinese that includes all the operation you need :)

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download