Solutions to Python Chinese annotation errors

I recently started learning Python and found that once there are Chinese comments in the code, errors will be reported

Cause

If there are non ASCII characters in the file, you need to specify the encoding Declaration on the first or second line

Solution

Add such a sentence in the first or second line
# — Coding: UTF-8–

Perfect solution

Similar Posts: