开开心心happyheart 2023-06-28 18:05 采纳率: 81.8%
浏览 24

utf-8无法解编码,如何解决?

大无语,utf-8无法解编码,主要是这在库里面,而且文件有

# -*- coding : utf-8 -*-
# coding: utf-8

img


完整报错内容:

Traceback (most recent call last):
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\threadpool.py", line 173, in __run_task
    thread_result.set(func(*args, **kwargs))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 0: invalid start byte
2023-06-28T09:38:38Z (<ThreadPoolWorker at 0x21c8b505e08 thread_ident=0x2f14 threadpool-hub=<Hub at 0x21c8b439098 thread_ident=0x4090>>, <built-in function gethostbyaddr>) failed with UnicodeDecodeError
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm 2023.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2023.1.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "X:\other\610web\main.py", line 60, in <module>
    server.serve_forever()
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\baseserver.py", line 398, in serve_forever
    self.start()
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\baseserver.py", line 336, in start
    self.init_socket()
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\pywsgi.py", line 1546, in init_socket
    self.update_environ()
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\pywsgi.py", line 1558, in update_environ
    name = socket.getfqdn(address[0])
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\_socketcommon.py", line 304, in getfqdn
    hostname, aliases, _ = gethostbyaddr(name)
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\_socketcommon.py", line 276, in gethostbyaddr
    return get_hub().resolver.gethostbyaddr(ip_address)
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\resolver\thread.py", line 66, in gethostbyaddr
    return self.pool.apply(_socket.gethostbyaddr, args, kwargs)
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\pool.py", line 161, in apply
    return self.spawn(func, *args, **kwds).get()
  File "src\\gevent\\event.py", line 329, in gevent._gevent_cevent.AsyncResult.get
  File "src\\gevent\\event.py", line 359, in gevent._gevent_cevent.AsyncResult.get
  File "src\\gevent\\event.py", line 347, in gevent._gevent_cevent.AsyncResult.get
  File "src\\gevent\\event.py", line 327, in gevent._gevent_cevent.AsyncResult._raise_exception
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\_compat.py", line 66, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\段禹珩\AppData\Roaming\Python\Python37\site-packages\gevent\threadpool.py", line 173, in __run_task
    thread_result.set(func(*args, **kwargs))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 0: invalid start byte
  • 写回答

2条回答 默认 最新

  • Hi 小朋友 2023-06-28 18:23
    关注

    请发你自己写的代码,python内置代码是不会出错的

    评论

报告相同问题?

问题事件

  • 创建了问题 6月28日

悬赏问题

  • ¥50 如何在不能联网影子模式下的电脑解决usb锁
  • ¥20 服务器redhat5.8网络问题
  • ¥15 如何利用c++ MFC绘制复杂网络多层图
  • ¥20 要做柴油机燃烧室优化 需要保持压缩比不变 请问怎么用AVL fire ESE软件里面的 compensation volume 来使用补偿体积来保持压缩比不变
  • ¥15 python螺旋图像
  • ¥15 算能的sail库的运用
  • ¥15 'Content-Type': 'application/x-www-form-urlencoded' 请教 这种post请求参数,该如何填写??重点是下面那个冒号啊
  • ¥15 找代写python里的jango设计在线书店
  • ¥15 请教如何关于Msg文件解析
  • ¥200 sqlite3数据库设置用户名和密码