两点水

pull/1/head
347073565@qq.com 2017-12-22 16:47:33 +08:00
parent 1b69364df2
commit f856b62e6f
14 changed files with 42 additions and 40 deletions

View File

@ -6,7 +6,7 @@ Python 是著名的“龟叔” Guido van Rossum 在 1989 年圣诞节期间,
这是 2017 年 2 月编程语言排行榜 TOP20 榜单:
![2 月编程语言排行榜 TOP20 榜单.png](https://user-gold-cdn.xitu.io/2017/6/18/1ed5d77b644cdd252699e7b2bfd772c5)
![2 月编程语言排行榜 TOP20 榜单.png](http://upload-images.jianshu.io/upload_images/2136918-f7fc786f001cbfc0?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
还有就是 Top 10 编程语言 TIOBE 指数走势:

View File

@ -24,7 +24,8 @@ print(list1[0:2])
输出的结果:
![访问 List列表中的值](https://user-gold-cdn.xitu.io/2017/6/21/eb8c85eb2cfccc112dbb891536014113)
![访问 List列表中的值](http://upload-images.jianshu.io/upload_images/2136918-ab562ada6ba08848?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 3、更新 List列表 ##
@ -43,7 +44,7 @@ print(list1)
输出的结果:
![更新 List列表](https://user-gold-cdn.xitu.io/2017/6/21/286bf8a5953d10aada532eb3d2909921)
![更新 List列表](http://upload-images.jianshu.io/upload_images/2136918-96de950da2563ac6?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 4、删除 List列表 ##
@ -60,7 +61,7 @@ print(list1)
输出的结果:
![删除 List列表](https://user-gold-cdn.xitu.io/2017/6/21/a2858b1cc9af6e02527119080a98b6a8)
![删除 List列表](http://upload-images.jianshu.io/upload_images/2136918-e761bf56f583089f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 5、List列表运算符 ##
@ -154,4 +155,4 @@ print(newUser)
```
![list的使用](https://dn-mhke0kuv.qbox.me/529c1895edddaad61deb.png)
![list的使用](http://upload-images.jianshu.io/upload_images/2136918-65d31cae9f8bb34d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@ -4,4 +4,4 @@
# 目录 #
![草根学Python List 和 Tuple](https://user-gold-cdn.xitu.io/2017/6/21/8135ae4d00e3ea07e3dae2df97fd9aaf)
![草根学Python List 和 Tuple](http://upload-images.jianshu.io/upload_images/2136918-4d3be05b7f048808?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@ -27,7 +27,8 @@ tuple4=(123,)
如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple又可以表示数学公式中的小括号这就产生了歧义因此Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值
![创建tuple](https://dn-mhke0kuv.qbox.me/f4b7a62091fb5d4f206f.png)
![创建tuple](http://upload-images.jianshu.io/upload_images/2136918-2072470ffe7cbee7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 2、tuple元组的索引 ##
@ -50,7 +51,7 @@ print(tuple2[0])
输出的结果:
![访问 tuple](https://dn-mhke0kuv.qbox.me/72844216bda8bc3e4a4b.png)
![访问 tuple](http://upload-images.jianshu.io/upload_images/2136918-edfb7c9ebc7d5ab0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 4、修改 tuple (元组) ##

View File

@ -4,4 +4,4 @@
# 目录 #
![草根学Python Dict 和 Set](https://user-gold-cdn.xitu.io/2017/6/25/e56136d9dd32653bd7db19de0969e29d)
![草根学Python Dict 和 Set](http://upload-images.jianshu.io/upload_images/2136918-726716aa6ab762fd?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@ -79,7 +79,7 @@ print(set1)
因为 set 是一个无序不重复元素集,因此,两个 set 可以做数学意义上的 union(并集), intersection(交集), difference(差集) 等操作。
![set集合运算](https://user-gold-cdn.xitu.io/2017/6/23/9afd2a3081e9d618cc55bf859b545d12)
![set集合运算](http://upload-images.jianshu.io/upload_images/2136918-733b1d1071f772bd?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
例子:

View File

@ -4,7 +4,7 @@
循环语句的一般形式如下:
![python循环语句](https://user-gold-cdn.xitu.io/2017/6/23/d0761ec24b83fea3d7008c29074ba5cb)
![python循环语句](http://upload-images.jianshu.io/upload_images/2136918-eaaae2fbfec3330f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Python 提供了 for 循环和 while 循环,当然还有一些控制循环的语句:
@ -105,7 +105,7 @@ else:
它的流程图基本如下:
![for循环的流程图](https://user-gold-cdn.xitu.io/2017/6/26/235ff5c72862b213486e0bf23852a245)
![for循环的流程图](http://upload-images.jianshu.io/upload_images/2136918-a0728c1c488238af?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
基本的语法格式:

View File

@ -6,7 +6,7 @@ Python 程序语言指定任何非 0 和非空null值为 True0 或者 n
执行的流程图如下:
![if语句流程图](https://user-gold-cdn.xitu.io/2017/6/23/9b796437c2f0ac3ba1dc5009de091031)
![if语句流程图](http://upload-images.jianshu.io/upload_images/2136918-4ee2486190450a1a?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 1、if 语句的基本形式 ##

View File

@ -2,9 +2,9 @@
第一次建学习群,而且是 Python 的学习群,虽然之前深入学习和工作都是 Android 相关的,最近学起来 Python ,真的很好玩,所以创了个微信群,希望童鞋们进群学习讨论。也可以直接加我微`androidwed`拉进群。也欢迎大家在 [Gitbook](https://www.readwithu.com/) 中提出文章的不足。
![Python学习群](https://user-gold-cdn.xitu.io/2017/6/27/aaeb2c5817779cef45fee80bf544ff30)
![Python学习群](http://upload-images.jianshu.io/upload_images/2136918-f3f0c60ce12e5a92?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
# 目录 #
![草根学Python 条件语句和循环语句](https://user-gold-cdn.xitu.io/2017/6/27/b09d98a2f40724326f8b04b2049236b5)
![草根学Python 条件语句和循环语句](http://upload-images.jianshu.io/upload_images/2136918-32902eec93d9ffc1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@ -31,7 +31,7 @@ print( b )
**可更改的类型**:变量赋值 `a = [1,2,3,4,5,6]` ,就是生成一个对象 list list 里面有 6 个元素,而变量 a 指向 list `a[2] = 5`则是将 list a 的第三个元素值更改,这里跟上面是不同的,并不是将 a 重新指向,而是直接修改 list 中的元素值。
![指向问题](https://user-gold-cdn.xitu.io/2017/6/27/d23fb1478065a0bcc19949cfbc88c5a0)
![指向问题](http://upload-images.jianshu.io/upload_images/2136918-31b1031d75e1cec9?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
这也将影响到函数中参数的传递了:

View File

@ -24,7 +24,7 @@ print(sum(1,2))
这个示例,还通过内置函数`isinstance()`进行数据类型检查,检查调用函数时参数是否是整形和浮点型。如果参数类型不对,会报错,提示 `参数类型错误`,如图:
![检查函数参数是否正确](https://user-gold-cdn.xitu.io/2017/6/28/d844f6a7b80370797dfea8f251f2a709)
![检查函数参数是否正确](http://upload-images.jianshu.io/upload_images/2136918-cfe5907d67e912d8?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
当然,函数也可以返回多个值,具体实例如下:

View File

@ -4,4 +4,4 @@
# 目录 #
![草根学Python 函数](https://user-gold-cdn.xitu.io/2017/6/29/a5a5a69256f99d6eba4799bf837bc2cc)
![草根学Python 函数](http://upload-images.jianshu.io/upload_images/2136918-be9226fe109027f3?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@ -119,7 +119,7 @@ for x in fibon(1000000):
运行的效果:
![计算斐波那契数列的生成器](https://user-gold-cdn.xitu.io/2017/7/2/7b45fa54beb097a3037954b85a9a4d99)
![计算斐波那契数列的生成器](http://upload-images.jianshu.io/upload_images/2136918-304e50af22b787ce?imageMogr2/auto-orient/strip)
你看,运行一个这么打的参数,也不会说有卡死的状态,因为这种方式不会使用太大的资源。这里,最难理解的就是 generator 和函数的执行流程不一样。函数是顺序执行,遇到 return 语句或者最后一行函数语句就返回。而变成 generator 的函数,在每次调用 next() 的时候执行,遇到 yield语句返回再次执行时从上次返回的 yield 语句处继续执行。

View File

@ -4,4 +4,4 @@
# 目录 #
![草根学Python 迭代器和生成器](https://user-gold-cdn.xitu.io/2017/7/2/a11f2519b863b178ebc91fe2134aa7f6)
![草根学Python 迭代器和生成器](http://upload-images.jianshu.io/upload_images/2136918-b350c0e98ca47183?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)