首页> 开发问题 >其它问题 其它问题
Python“Non-ASCII character 'xe5' in file”报错问题
作者:小萝卜 2019-12-06 【 其它 】 浏览 1800
简介Python默认是以ASCII作为编码方式的,如果在自己的Python源码中包含了中文(或者其他非英语系的语言),此时即使你把自己编写的Python源文件以UTF-8格式保存了,但实际上,这依然是不行的。
出现问题的原因:
Python默认是以ASCII作为编码方式的,如果在自己的Python源码中包含了中文(或者其他非英语系的语言),此时即使你把自己编写的Python源文件以UTF-8格式保存了,但实际上,这依然是不行的。
解决办法很简单,只要在文件开头加入下面代码就行了。特别注意:上面这条语句一定要加在源代码的第一行!!!
# -*- coding: UTF-8 -*-
很赞哦! (0)
相关文章
- pycharm无法识别自己的文件夹的程序
- 报错:configure: error: no acceptable C compiler found in $PATH
- module 'torch' has no attribute 'gesv'
- git中报unable to auto-detect email address
- GitHub 上传文件过大报错:remote: error: GH001: Large files detected.
- ImportError: cannot import name 'BaseDataset' from 'src.dataset'
- 创建Maven项目时提示web.xml is missing and <failOnMissingWebXml> is set to true错误解决方案
- TypeError: 'newline' is an invalid keyword argument for this function 错误解决
- tf.matmul()报错expected scalar type Float but found Double
- VMWARE虚拟机安装64位系统此主机支持IntelVTx 但IntelVTx处于禁用状态
