python中的常见错误

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 一种字符编码



posted @ 2021-04-22 08:49  晚风踩着云  阅读(241)  评论(0编辑  收藏  举报