python中的常见错误

时间:2021-04-22 16:31:44   收藏:0   阅读:0

2.2.1名字错误

名字错误:python 的关键字写错了。 

NameError: name python3 is not defined

 

 现象:

 

技术图片

 

 

2.2.2语法错误

技术图片

SyntaxError: invalid syntax 

 

无效的语法:Java 和 JS 一行结束用分号“;”Python 用的换行

2.2.3缩进错误

  技术图片

 

 

NameError: name python3 is not defined

 

缩进错误:代码中有空格,没有对齐,Python 中缩进代表下一级(分支) 第一张 

第一节 第二节 

 

2.2.4中文乱码错误

 技术图片

 

 

SyntaxError: Non-ASCII character \xe8 

 

Python 2.x 默认不支持中文,具体原因,等到介绍 字符编码 时给大家讲解 Python 2.x 的解释器名称是 python
Python 3.x 的解释器名称是 python3 

 

2.2.5基础单词

* error 错误
* name 
名字
* defined 
已经定义,default 默认值 * syntax 语法

* invalid  valid 验证

* Indentation 索引
* unexpected 
意外的,不期望的 * character 字符 char 

* line col 

* encoding 编码
* declared 
声明
* details 
细节,详细信息 * ASCII 一种字符编码



评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!