I want to download all images from a website using Python. I already have the header of the HTML file, so I use os.mkdir()to create the folder, but the header contains Chinese. When the following code is executed on the Raspberry Pi (OS: Debian), an exception is thrown:
UnicodeEncodeError: ascii codec cannot encode characters at positions 20-38: serial number not in range (128)
try:
os.mkdir(path)
except:
print "create folder failed"
continue
Everything is fine if I run the code on my Mac.
I searched for the problem and tried the code below, but it does not work.
reload(sys)
sys.setdefaultencoding('utf-8')
Update:
I changed my code a lot and read some articles about unicode, utf-8.etc. But every time I run the code on Raspberry Pi, it is crushed. Then I installed the Debian OS (which I installed on my Raspberry Pi) on the PC, ran the code on it, everything is fine.
, , SSH.
Debian , . Mac SSH , , "Unicode..." - .
, , : -)