notepad++ Editor write Python pay attention to using UTF-8 encoding

Source: Internet
Author: User

Language: python3.4

Text Editor: notepad++

Error:syntaxerror: (Unicode error) ' Utf-8 ' codec can ' t decode byte 0xb4 in position 0:invalid start byte

Description: Use the notepad++ editor to write Python programs. When using a three-quote "' Chinese string, for example (' ' Medium ' size '), then run the error.

Experimental resolution process:

Error procedure:

Create the file test.py. Python code:

    1. #!/usr/bin/env python
    2. #-*-Coding:utf-8-*-
    3. ‘‘‘
    4. Medium size
    5. ‘‘‘


Operation Error:

    1. E:\Program files\python3. 4\01jobs>python test.py
    2. File "test.py", line 9
    3. " "
    4. SyntaxError: (Unicode error) ' Utf-8 ' codec can ' t decode byte 0xb4 in position 0:
    5. Invalid start byte


Basics: The default encoding format in Python is utf-8.

Solution to the problem:

Use notepad++ to open test.py discovery file storage format is ANSI

Just change the format of the saved file to UTF-8.

Open test.py >> menu bar with notepad++ only encoding (encoding) >> Convert to UTF-8 (converted to utf-8)

In the run test.py problem resolution

notepad++ Editor write Python pay attention to using UTF-8 encoding

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.