Python3 编译中文字串报错解决方案
问题:
Python3.6.5 版本中,程序有中文,运行时出现以下error:
SyntaxError: Non-UTF-8 code starting with '\xb2' in file XXX.py on line 8, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Root cause:
导致出错的根源就是编码问题。
解决方案是:
在程序最上面加上:# coding=gbk
这样程序就可以正常运行了。
解决中文乱码问题在程序最前面:
#encoding=utf-8
#encoding=gb2312
#unicoding=gb2312
尝试以上几种看是否能将问题解决,目前Geany编译器时不时报中文问题,目前是以上方法解决,等熟悉再分享原因
Python3 编译中文字串报错解决方案的更多相关文章
- visual2013 的 MVC 4中连接数据库报错解决方案
win7 64位安装vs2013后连接远程数据库出现下面的问题:A first chance exception of type 'System.AccessViolationException' ...
- Python3.x:关于urllib中urlopen报错问题的解决方案
Python3.x:关于urllib中urlopen报错问题的解决方案 调用:urllib.urlopen(url) 报错:AttributeError: 'module' object has no ...
- python接口自动化:python3.6中import Crypto.Hash报错的解决方案
一:问题 python3.6中算法加密引入包Crypto报错,即便安装了: pip install crypto pip install pycrypto pip install pycryptodo ...
- C语言开发中常见报错的解决方案
C语言开发中常见报错的解决方案 整理来源于网络,侵权请通知删除.*禁止转载 ---- fatal error C1003: error count exceeds number; stopping c ...
- Python3.x:import urllib2报错解决方案
Python:import urllib2报错解决方案 python2和3有些不一样: python2:输出为print 'hello world' python3:输出为print('hello w ...
- python3.4中自定义wsgi函数,make_server函数报错问题
别的不多说,先上代码 #coding:utf-8 from wsgiref.simple_server import make_server def RunServer(environ, start_ ...
- 【maven】【IDEA】idea中使用maven编译项目,报错java: 错误: 找不到符号 【2】
=================================================================================== idea中使用maven编译项目 ...
- Maven编译中使用${env}与直接启动tomcat会报错的问题处理
Maven编译中使用${env}与直接启动tomcat会报错的问题处理 在Run/Debug Configurations中,设置 Before lauch:Build, Build Artifact ...
- python2中的unicode()函数在python3中会报错:
python2中的unicode()函数在python3中会报错:NameError: name 'unicode' is not defined There is no such name in P ...
随机推荐
- 【分享】自己写的一个可空的DateTimePicker控件-附源码
最近这段时间在重构以前的一个项目,其中有一项就是要把DateTimePicker控件值可空.大家都知道的DateTimePicker值为DateTime类型,DateTime类型值不能等于Null.但 ...
- dubbo介绍及其使用案例
dubbo介绍及其使用案例 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果 ...
- mysql系列之1.mysql基础
非关系型(NOSQL)数据库 键值存储数据库: memcached / redis / memcachedb / Berkeley db 列存储数据库: Cassandra / Hba ...
- 2017-2018-1 20179209《Linux内核原理与分析》第六周作业
一.分析system_call中断处理过程 实验 下载最新menu,并在test.c中增加mkdir与mkdir-asm函数原型 rm menu -rf git clone https://githu ...
- BZOJ1217: [HNOI2003]消防局的设立
BZOJ1217: [HNOI2003]消防局的设立 Description 2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地. 起初为了节约材料,人类只修建了n-1条道路来连接这些基地 ...
- Spring/Java error: namespace element 'annotation-config' … on JDK 1.5 and higher
Extract the jar file: mkdir spring cd spring jar xvf ../spring.jar Check the Spring version in META- ...
- VM tools安装错误The path "" is not a valid path to the xx generic kernel headers.
VMWARE TOOLS安装提示THE PATH IS NOT A VALID PATH TO THE GENERIC KERNEL HEADERSI solved this problem, I g ...
- Android Studio快速添加Gson Gsonformat
一.Android Studio快速添加Gson 具体操作: 1.File->Project Structure: 2.app->Dependencies->" ...
- VMware和Centos系统安装
1.Linux发行版的选择 2.vmware创建一个虚拟机(centos) 3.安装配置centos7 4.xshell配置连接虚拟机(centos) 选择性 pc可以选择 -纯系统 Linux/wi ...
- Linux- Linux自带定时调度Crontab使用详解
Linux自带定时调度Crontab使用详解 在Linux当中,有一个自带的任务调度功能crontab,它是针对每个用户,每个用户都可以调度自己的任务. 示例:每分钟执行一次,将时间写入到指定文件当中 ...