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

'gbk' codec can't decode byte 0x93 in position 978: illegal multibyte sequence and then a bytes-like object is required, not 'str' #146

Open
Ailing-Zou opened this issue Dec 10, 2019 · 2 comments

Comments

@Ailing-Zou
Copy link

Hi, when I first run this code,

File "D:/transformer/prepro.py", line 37, in
_prepro = lambda x: [line.strip() for line in open(x, 'r').read().split("\n")
UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 978: illegal multibyte sequence

After I change this row into
_prepro = lambda x: [line.strip() for line in open(x, 'rb).read().split("\n")
if not line.startswith("<")]
a bytes-like object is required, not 'str'.

So what kind of way should I use to open this file?
Look forward to reply.

@lushunn
Copy link

lushunn commented Sep 21, 2020

adding encoding='utf-8' in open function when you open file

@KMY-SEU
Copy link

KMY-SEU commented Oct 11, 2020

adding encoding='utf-8' in open function when you open file

NB!

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

3 participants