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: 'utf-8' codec can't decode byte 0xc1 in position 14: invalid start byte #44

Open
FXLP opened this issue Nov 10, 2020 · 1 comment

Comments

@FXLP
Copy link

FXLP commented Nov 10, 2020

when I add a new txt, it was wrong like this:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\86152\AppData\Local\Programs\Python\Python39\lib\tkinter_init_.py", line 1885, in call
return self.func(*args)
File "C:\Users\86152\Desktop\YEDDA-py3\YEDDA.py", line 251, in onOpen
text = self.readFile(fl)
File "C:\Users\86152\Desktop\YEDDA-py3\YEDDA.py", line 262, in readFile
text = f.read()
File "C:\Users\86152\AppData\Local\Programs\Python\Python39\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 14: invalid start byte

how can I solve the problem?

@feiba54
Copy link

feiba54 commented Apr 1, 2021

Maybe change text = f.read() into text = f.read(encoding = "GBK") or the corresponding encoding for your txt?

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