Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何解决错误 UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 132: character maps to <undefined> decoding with 'windows-1251' codec failed #45

Open
luckypoem opened this issue Oct 21, 2024 · 1 comment

Comments

@luckypoem
Copy link

hi.
我运行python3 mvrk.py --config ./demo_src/config.py --source_dir ./demo_src/ --build_dir ./dist/ 后,显示:

Site prefix: /
Source dir: ./demo_src/
Build dir: ./dist/
Start clean...done.
Loading contents...
Traceback (most recent call last):
File "C:\Users\12799\maverick\Maverick\Utils.py", line 99, in safe_read
return f.read()
^^^^^^^^
File "", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 131943: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\12799\maverick\mvrk.py", line 45, in
main()
File "C:\Users\12799\maverick\mvrk.py", line 41, in main
builder.build_all()
File "C:\Users\12799\maverick\Maverick\Builder.py", line 134, in build_all
content = Content(content_path)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\12799\maverick\Maverick\Content.py", line 30, in init
content = safe_read(path)
^^^^^^^^^^^^^^^
File "C:\Users\12799\maverick\Maverick\Utils.py", line 104, in safe_read
return content.decode(encoding=encoding)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\encodings\cp1251.py", line 15, in decode
return codecs.charmap_decode(input,errors,decoding_table)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 132: character maps to
decoding with 'windows-1251' codec failed

12799@DESKTOP-B6LK9IO MINGW64 ~/maverick$

谢谢回复!

@AlanDecode
Copy link
Owner

看起来主要是因为你的文件用了无法识别的文件编码,可以尝试转换成常见的编码,比如 utf-8 试试看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants