高洛峰2017-04-18 09:21:40
You just need to add:
at the beginning of the file# -*- coding: utf-8 -*-
or:
# coding: utf-8
PHP中文网2017-04-18 09:21:40
If you want to write Chinese in the py file of python2,
The first or second line
should add the following line of comments declaring the file encoding, otherwise python2 will use ASCII encoding by default.
#-*- coding:utf-8 -*-
Optional formats are
# -*- coding: <encoding name> -*-
PHP中文网2017-04-18 09:21:40
Add at the top of each file that needs to support Chinese: #coding:utf-8