![b9d59641e5c3e9ba7a2235aa01496b51.png](https://img-blog.csdnimg.cn/img_convert/b9d59641e5c3e9ba7a2235aa01496b51.png)
一 学习总结
原定上周就已经将猴子过关中第二关学习完全,因为觉得有部分不熟悉又找其他学习资源练习了一周。和大学学习的C语言、工作自学的VB语言有所不同,Pyhton简单不需要每个变量进行定义数据类型;和Sql语言不同,Pyhton有明显区分大小写。
在学习中,总结编写代码时有几个经常犯的错误浪费了时间,1:Python大小写是一定需要区分,不然无法得到你想要的输出;2:Python中不同语句的缩进有从属关系,如if/while/for等,也区分了局部和全局变量;3:Python中的常见的语法错误,如中英文输入法不同字符导致报错;4:复杂程序编写需要先梳理分析步骤,必要时制定流程图,会大大减少编写代码时的错误。
二 基础知识回顾
如下为百度脑图整理的Python基础学习的思维导图(可能图片看不太清楚),主要分为四个部分:数据类型、函数和循环/条件判断、模块、数据结构。
![642396904fb0feefecfed659b8908a14.png](https://img-blog.csdnimg.cn/img_convert/642396904fb0feefecfed659b8908a14.png)
1、数据类型
字符型(String):
访问字符串中的值([]、[n:]、[::-n]);
内置函数(startwith/endwith;count();find();join();partition();replace();split();strip())
![0fae01ab72ed1fa05d03a202f92928d2.png](https://img-blog.csdnimg.cn/img_convert/0fae01ab72ed1fa05d03a202f92928d2.png)
数值型(Number):
int、long、float(存在精度缺失,可使用Decimal)、complex
![5e0aecf395a77767c97de02319ac37b8.png](https://img-blog.csdnimg.cn/img_convert/5e0aecf395a77767c97de02319ac37b8.png)
列表(List):用符号[]表示列表,中间的元素可以是任何类型,用逗号分隔。
访问列表中的值,和访问字符串中一样;
内置函数:len()、max()、min()、list()
方法:append()、extend()、insert()、pop()、sort()、count()、index()
![b85f71661a38ef2aedd8aafef061c2a0.png](https://img-blog.csdnimg.cn/img_convert/b85f71661a38ef2aedd8aafef061c2a0.png)
![e4a1f136f4c0e6470219a96badc1e7c2.png](https://img-blog.csdnimg.cn/img_convert/e4a1f136f4c0e6470219a96badc1e7c2.png)
元组(Tuple):用符号()表示元组,中间元素有逗号分隔开,属于不可变变量
集合(Set):无重复元素的容器,用符号{}表示集合,中间元素有逗号分隔开,属于可变变量
![93b3254c5888a05000d4004e0c61930b.png](https://img-blog.csdnimg.cn/img_convert/93b3254c5888a05000d4004e0c61930b.png)
字典(Dict):有键值对组成,用符号{}表示字典,中间元素有逗号分隔开,属于可变变量,格式为dictionary = {key:value},键不可变类型且唯一。
取value值:dict[key] 修改value值:dict[key]=修改后value 删除:del dict[key]
方法:clear()、fromkeys()、get()、has_key()、items()、update()、keys()
![89549e01aad835ea1814bbeba6a5049f.png](https://img-blog.csdnimg.cn/img_convert/89549e01aad835ea1814bbeba6a5049f.png)
![907ab813f1c5052bc47b2df9bab72337.png](https://img-blog.csdnimg.cn/img_convert/907ab813f1c5052bc47b2df9bab72337.png)
布尔值(Boolean):返回True和False
空值(None )
![bbaa5607b2af969148f28b14300034ea.png](https://img-blog.csdnimg.cn/img_convert/bbaa5607b2af969148f28b14300034ea.png)
2、函数和循环条件判断
循环语句:for和while循环
continue为跳过此次循环中的代码块、break为跳出循环
![dd137e952749e16d72fd7a9ab3f649dc.png](https://img-blog.csdnimg.cn/img_convert/dd137e952749e16d72fd7a9ab3f649dc.png)
![d31ca59a48f0472aa6cbc86421e54897.png](https://img-blog.csdnimg.cn/img_convert/d31ca59a48f0472aa6cbc86421e54897.png)
![11ca67cef3122d4873d3a761f70e333e.png](https://img-blog.csdnimg.cn/img_convert/11ca67cef3122d4873d3a761f70e333e.png)
![76f324e8351c0057e4d8fc196f67c2af.png](https://img-blog.csdnimg.cn/img_convert/76f324e8351c0057e4d8fc196f67c2af.png)
条件语句:ifelseelif:
![e8172f43e8a381163542354f7ad35f8e.png](https://img-blog.csdnimg.cn/img_convert/e8172f43e8a381163542354f7ad35f8e.png)
函数:
Def 函数名(参数):
代码块
(return )
![b0342becb22b2b63c962dba8b3a1d1f5.png](https://img-blog.csdnimg.cn/img_convert/b0342becb22b2b63c962dba8b3a1d1f5.png)
![5a043048c21982b386155bf399db3033.png](https://img-blog.csdnimg.cn/img_convert/5a043048c21982b386155bf399db3033.png)
![ff1738f23a459086c58f1938c84597c7.png](https://img-blog.csdnimg.cn/img_convert/ff1738f23a459086c58f1938c84597c7.png)
3、模块
![1a97ea36e13081a69513357f852f516b.png](https://img-blog.csdnimg.cn/img_convert/1a97ea36e13081a69513357f852f516b.png)
![17826657ceb89554f570e788090fe04e.png](https://img-blog.csdnimg.cn/img_convert/17826657ceb89554f570e788090fe04e.png)
4、数据结构
队列:先进先出
栈:后进先出
排序字典
![d4768d758f12a16545768e1125bfb391.png](https://img-blog.csdnimg.cn/img_convert/d4768d758f12a16545768e1125bfb391.png)
![b03b8ee506e1158e894457d0286ce247.png](https://img-blog.csdnimg.cn/img_convert/b03b8ee506e1158e894457d0286ce247.png)
![bd550877cd06f301ff6f252ca9e940e1.png](https://img-blog.csdnimg.cn/img_convert/bd550877cd06f301ff6f252ca9e940e1.png)
总的来说,基本框架和语法已经了解,距离掌握还差编程的练习和异常报错的处理,这两点还是需要加强!