I'm trying to switch python3. I believe there is utf8 encoding by default. Should I still use encoding declaration at the beginning every file?
# -*- coding: utf-8 -*-
解决方案
Because the default is UTF-8, you only need to use that declaration when you deviate from the default, or if you rely on other tools (like your IDE or text editor) to make use of that information.
In other words, as far as Python is concerned, only when you want to use an encoding that differs do you have to use that declaration.
Note that it only applies to how Python reads the source code. It doesn't apply to printing, opening files, or any other I/O operations. For more details on Python, Unicode, and encodings, I strongly urge you to read the Python Unicode HOWTO, or the very thorough Pragmatic Unicode talk by Ned Batchelder.