When I run the following program from Atom, I get an error.Please let me know
error:
Traceback (most recent call last):
File "C:\Users\Katsu\Desktop\python\python.py", line 6, in <module>
data=f.read()
UnicodeDecodeError: 'cp932' codec can't decode byte 0x81 in position21: illegal multibyte sequence
program:
import re
source='english_words_01.txt'
with open(source) asf:
data=f.read()
print(data)
I guess this is it.
The Python program in Windows cannot read UTF-8 text files
Python text file input/output on Windows is set to AnsiCodePage (shift JIS=cp932) by default.
The article around here also shows how to deal with situations and environmental variables.
Default UTF-8 on Python on Windows
Unicode HOWTO
However, encoding will still be mixed, so encoding
for each file should be specified.
Also note that using common features such as python.py
or test
or the name of the module you are trying to load can cause problems.It's good to search and remember the common mistakes of beginners
© 2025 OneMinuteCode. All rights reserved.