python3:(unicode error) 'utf-8' codec can't decode

surroundings:

Operating System: win7 Ultimate

Language: python3.4

Text Editor: vim, notepad ++

报错:SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xb4 in position 0:invalid start byte

Description: Yes I opened using vim editor to write python program. When using a triple quotes' '' Chinese character string, such as ( '' 'medium size' ''), after running on the error.

Experiments resolution process:

Error process:

Create a file test.py. python code:

#!/usr/bin/env python

# -*- coding:utf-8 -*-


'''

大小中等

'''


Run error:

E:\Program Files\python3.4\01jobs>python test.py

File "test.py", line 9

'''

SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xb4 in position 0:

invalid start byte


Basics: The default encoding format in python is utf-8. So how will reportedly not press utf-8 to decode le? Confused ah.

 

Problem solving:

Test.py found using notepad ++ open file storage format is ANSI

As long as the format for saving files into UTF-8 just fine

Only to open the notepad ++ test.py >> menu bar Encoding (encoding) >> Convert to UTF-8 (converted to utf-8)

Solve problems in running test.py

 

Published 96 original articles · won praise 161 · views 220 000 +

Guess you like

Origin blog.csdn.net/qq_26803795/article/details/82465873