


本篇文章给大家带来的内容是关于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 -*- ''' 大小中等 '''
运行报错:
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
基本知识:在python中默认的编码格式是 utf-8。
问题的解决:
使用notepad++打开test.py发现文件存储的格式是ANSI
只要将保存文件的格式换成UTF-8就好了
只用notepad++打开test.py >> 菜单栏Encoding(编码)>> Convert to UTF-8(转化成utf-8)
在运行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!

Notepad is a free, open-source text and code editor offering syntax highlighting, auto-completion, macro recording, powerful search, and a plugin system. Its advantages over other editors include enhanced code readability, efficient search/replace

This article compares Notepad and Notepad , highlighting Notepad 's superior features for coding. Notepad offers syntax highlighting, code completion, and extensive plugin support, unlike the basic functionality of Notepad. Therefore, Notepad

This article describes Notepad, a basic Windows text editor. It details its functions—text editing, saving, opening, and searching—and limitations. While usable for simple text tasks, its lack of syntax highlighting, code completion, and debugging

This article explains that Notepad is pre-installed in Windows and requires no installation. It addresses common issues accessing or using Notepad, offering troubleshooting steps. It also details installing the separate, more advanced text editor,

This article explains how to improve JSON data readability in Notepad . It focuses on using Notepad 's syntax highlighting and suggests external JSON formatters and validators for reliable formatting and syntax checking, as Notepad lacks built-i

Notepad lacks built-in language settings. To use Chinese, users must change their operating system's language settings to Chinese (Simplified or Traditional), then restart their computer or Notepad . Notepad 's interface language reflects the

This article explains how to convert unstructured Notepad text to JSON format. It highlights the lack of a direct conversion method, emphasizing the need for manual structuring or scripting (Python, JavaScript) for automation. Spreadsheet software

This Q&A clarifies Notepad's presence on Windows computers. It confirms Notepad's near-universal pre-installation as a core Windows component, accessible via search or File Explorer, except in rare cases of highly customized or corrupted system


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
