tenos
tenos

Reputation: 959

builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 17: invalid continuation byte

(WingIDE with python 3.3.0)

i write a very simpe python source file test.py,there are only two lines in the file

print('123')
#因为是灰度图所以shape(im)返回二元组,彩色图则返回三元组

the second line is Chinese annotation, when i run this file,it shows excepton as follow: builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 17: invalid continuation byte

when I delete the second line, it's ok

Upvotes: 2

Views: 4309

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799150

The default encoding for source files is UTF-8. For everything else, there's PEP 263.

#!/usr/python
# -*- coding: gb2312 -*-

print('123')
#因为是灰度图所以shape(im)返回二元组,彩色图则返回三元组

Upvotes: 2

Related Questions