sylhare / Python

:snake: Projects in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 664: character maps to <undefined>

sylhare opened this issue · comments

When running the fix_space.py on Animal.py. It seems there's a charactere that is not recognized.
The file is utf-8 encoded and there's no peculiar characters.

The error appear on line 67:

with open(path, 'r') as file:
            new = [line.rstrip() for line in file]

Well after some researchs, it seems we need to specify the encoding in the open function. Thus using:

with open(path, 'r', encoding='utf-8') as file:
            new = [line.rstrip() for line in file]

And now it seems to work.
Here are some links for documentation: