Home > Development Tools > notepad > body text

The encoding format you need to pay attention to when running python programs in the notepad++ editor

不言
Release: 2018-09-26 17:09:10
Original
5189 people have browsed it

本篇文章给大家带来的内容是关于notepad++编辑器中运行python程序时需要注意的编码格式,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

语言:python3.4

文本编辑器:notepad++

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

说明:使用notepad++编辑器写python程序。当在使用三引号'''中文字符串,例如('''大小中等'''),之后运行就报错了。

实验解决过程:

错误过程:

创建文件test.py。python代码:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
大小中等
'''
Copy after login

运行报错:

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
Copy after login

基本知识:在python中默认的编码格式是 utf-8。

问题的解决:

使用notepad++打开test.py发现文件存储的格式是ANSI

The encoding format you need to pay attention to when running python programs in the notepad++ editor

只要将保存文件的格式换成UTF-8就好了

只用notepad++打开test.py >> 菜单栏Encoding(编码)>> Convert to UTF-8(转化成utf-8)

The encoding format you need to pay attention to when running python programs in the notepad++ editor

在运行test.py问题解决

The above is the detailed content of The encoding format you need to pay attention to when running python programs in the notepad++ editor. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!