From f856b62e6f7a15d938eb61406f037e51a9b3c97c Mon Sep 17 00:00:00 2001 From: "347073565@qq.com" <347073565@qq.com> Date: Fri, 22 Dec 2017 16:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=A4=E7=82=B9=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python1/Introduction.md | 4 ++-- python3/List.md | 9 +++++---- python3/Preface.md | 2 +- python3/tuple.md | 9 +++++---- python4/Preface.md | 2 +- python4/Set.md | 2 +- python5/Cycle.md | 14 +++++++------- python5/If.md | 6 +++--- python5/Preface.md | 4 ++-- python6/2.md | 8 ++++---- python6/3.md | 6 +++--- python6/Preface.md | 2 +- python7/4.md | 12 ++++++------ python7/Preface.md | 2 +- 14 files changed, 42 insertions(+), 40 deletions(-) diff --git a/python1/Introduction.md b/python1/Introduction.md index fd130d2..f227575 100644 --- a/python1/Introduction.md +++ b/python1/Introduction.md @@ -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 指数走势: @@ -20,4 +20,4 @@ Python 是高级编程语言,它有一个特点就是能快速的开发。Pyth 第一个缺点就是运行速度慢,和C程序相比非常慢,因为Python是解释型语言,你的代码在执行时会一行一行地翻译成CPU能理解的机器码,这个翻译过程非常耗时,所以很慢。而C程序是运行前直接编译成CPU能执行的机器码,所以非常快。 -第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。 \ No newline at end of file +第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。 diff --git a/python3/List.md b/python3/List.md index 9314699..860d08c 100644 --- a/python3/List.md +++ b/python3/List.md @@ -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) \ No newline at end of file +![list的使用](http://upload-images.jianshu.io/upload_images/2136918-65d31cae9f8bb34d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) diff --git a/python3/Preface.md b/python3/Preface.md index 66e412f..4e9a566 100644 --- a/python3/Preface.md +++ b/python3/Preface.md @@ -4,4 +4,4 @@ # 目录 # -![草根学Python(三) List 和 Tuple](https://user-gold-cdn.xitu.io/2017/6/21/8135ae4d00e3ea07e3dae2df97fd9aaf) \ No newline at end of file +![草根学Python(三) List 和 Tuple](http://upload-images.jianshu.io/upload_images/2136918-4d3be05b7f048808?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) diff --git a/python3/tuple.md b/python3/tuple.md index c5bb682..6bb08c1 100644 --- a/python3/tuple.md +++ b/python3/tuple.md @@ -25,9 +25,10 @@ tuple3=() tuple4=(123,) ``` -如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple,又可以表示数学公式中的小括号,这就产生了歧义,因此,Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值 +如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple,又可以表示数学公式中的小括号,这就产生了歧义,因此,Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值 + +![创建tuple](http://upload-images.jianshu.io/upload_images/2136918-2072470ffe7cbee7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) -![创建tuple](https://dn-mhke0kuv.qbox.me/f4b7a62091fb5d4f206f.png) ## 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 (元组) ## @@ -114,4 +115,4 @@ del tuple1 |len(tuple)|计算元组元素个数| |max(tuple)|返回元组中元素最大值| |min(tuple)|返回元组中元素最小值| -|tuple(seq)|将列表转换为元组| \ No newline at end of file +|tuple(seq)|将列表转换为元组| diff --git a/python4/Preface.md b/python4/Preface.md index 82a8a92..0c3221c 100644 --- a/python4/Preface.md +++ b/python4/Preface.md @@ -4,4 +4,4 @@ # 目录 # -![草根学Python(四) Dict 和 Set](https://user-gold-cdn.xitu.io/2017/6/25/e56136d9dd32653bd7db19de0969e29d) \ No newline at end of file +![草根学Python(四) Dict 和 Set](http://upload-images.jianshu.io/upload_images/2136918-726716aa6ab762fd?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) diff --git a/python4/Set.md b/python4/Set.md index 2c14a90..a07cf47 100644 --- a/python4/Set.md +++ b/python4/Set.md @@ -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) 例子: diff --git a/python5/Cycle.md b/python5/Cycle.md index 89e823b..5eb983d 100644 --- a/python5/Cycle.md +++ b/python5/Cycle.md @@ -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 循环,当然还有一些控制循环的语句: @@ -19,7 +19,7 @@ Python 提供了 for 循环和 while 循环,当然还有一些控制循环的 ```python -count = 1 +count = 1 sum = 0 while (count <= 100): sum = sum + count @@ -38,7 +38,7 @@ print(sum) 比如,上面的例子是计算 1 到 100 所有整数的和,当我们需要判断 sum 大于 1000 的时候,不在相加时,可以用到 break ,退出整个循环 ```python -count = 1 +count = 1 sum = 0 while (count <= 100): sum = sum + count @@ -57,7 +57,7 @@ print(sum) 有时候,我们只想统计 1 到 100 之间的奇数和,那么也就是说当 count 是偶数,也就是双数的时候,我们需要跳出当次的循环,不想加,这时候可以用到 break ```python -count = 1 +count = 1 sum = 0 while (count <= 100): if ( count % 2 == 0): # 双数时跳过输出 @@ -105,13 +105,13 @@ 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) 基本的语法格式: ```python for iterating_var in sequence: - statements(s) + statements(s) ``` 实例: @@ -129,7 +129,7 @@ e l l o - + 两 点 水 diff --git a/python5/If.md b/python5/If.md index 95f1029..caa2246 100644 --- a/python5/If.md +++ b/python5/If.md @@ -6,7 +6,7 @@ Python 程序语言指定任何非 0 和非空(null)值为 True,0 或者 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 语句的基本形式 ## @@ -46,7 +46,7 @@ else : 上面也说道,非零数值、非空字符串、非空 list 等,判断为True,否则为False。因此也可以这样写: ```python -num = 6 +num = 6 if num : print('Hello Python') ``` @@ -111,7 +111,7 @@ else : if ( java >= 80 and java < 90 ) or ( python >= 80 and python < 90): print('良好') - + ``` 输出结果: diff --git a/python5/Preface.md b/python5/Preface.md index 4e6bfa3..ce4be8b 100644 --- a/python5/Preface.md +++ b/python5/Preface.md @@ -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) \ No newline at end of file +![草根学Python(五) 条件语句和循环语句](http://upload-images.jianshu.io/upload_images/2136918-32902eec93d9ffc1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) diff --git a/python6/2.md b/python6/2.md index ffba1c2..76ba52c 100644 --- a/python6/2.md +++ b/python6/2.md @@ -9,7 +9,7 @@ def chagne_number( b ): b = 1 chagne_number(b) -print( b ) +print( b ) ``` 最后输出的结果为: @@ -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) 这也将影响到函数中参数的传递了: @@ -47,7 +47,7 @@ def chagne_number( b ): print('函数中一开始 b 的值:{}' .format( b ) ) b = 1000 print('函数中 b 赋值后的值:{}' .format( b ) ) - + b = 1 chagne_number( b ) @@ -73,7 +73,7 @@ def chagne_list( b ): print('函数中一开始 b 的值:{}' .format( b ) ) b.append(1000) print('函数中 b 赋值后的值:{}' .format( b ) ) - + b = [1,2,3,4,5] chagne_list( b ) diff --git a/python6/3.md b/python6/3.md index 0f06fb9..fdc17b9 100644 --- a/python6/3.md +++ b/python6/3.md @@ -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) 当然,函数也可以返回多个值,具体实例如下: @@ -35,7 +35,7 @@ def division ( num1, num2 ): # 求商与余数 a = num1 % num2 b = (num1-a) / num2 - return b , a + return b , a num1 , num2 = division(9,4) tuple1 = division(9,4) @@ -51,4 +51,4 @@ print (tuple1) (2.0, 1) ``` -认真观察就可以发现,尽管从第一个输出值来看,返回了多个值,实际上是先创建了一个元组然后返回的。回忆一下,元组是可以直接用逗号来创建的,观察例子中的 ruturn ,可以发现实际上我们使用的是逗号来生成一个元组。 \ No newline at end of file +认真观察就可以发现,尽管从第一个输出值来看,返回了多个值,实际上是先创建了一个元组然后返回的。回忆一下,元组是可以直接用逗号来创建的,观察例子中的 ruturn ,可以发现实际上我们使用的是逗号来生成一个元组。 diff --git a/python6/Preface.md b/python6/Preface.md index 14a4538..f05ffef 100644 --- a/python6/Preface.md +++ b/python6/Preface.md @@ -4,4 +4,4 @@ # 目录 # -![草根学Python(六) 函数](https://user-gold-cdn.xitu.io/2017/6/29/a5a5a69256f99d6eba4799bf837bc2cc) \ No newline at end of file +![草根学Python(六) 函数](http://upload-images.jianshu.io/upload_images/2136918-be9226fe109027f3?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) diff --git a/python7/4.md b/python7/4.md index 44015c5..684c0e9 100644 --- a/python7/4.md +++ b/python7/4.md @@ -65,7 +65,7 @@ def my_function(): for i in range(10): print ( i ) -my_function() +my_function() ``` 输出的结果: @@ -91,7 +91,7 @@ def my_function(): for i in range(10): yield i -print(my_function()) +print(my_function()) ``` 输出的结果: @@ -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 语句处继续执行。 @@ -136,9 +136,9 @@ def odd(): yield ( 5 ) o = odd() -print( next( o ) ) -print( next( o ) ) -print( next( o ) ) +print( next( o ) ) +print( next( o ) ) +print( next( o ) ) ``` 输出的结果: diff --git a/python7/Preface.md b/python7/Preface.md index 8db0eb3..22583dc 100644 --- a/python7/Preface.md +++ b/python7/Preface.md @@ -4,4 +4,4 @@ # 目录 # -![草根学Python(七) 迭代器和生成器](https://user-gold-cdn.xitu.io/2017/7/2/a11f2519b863b178ebc91fe2134aa7f6) \ No newline at end of file +![草根学Python(七) 迭代器和生成器](http://upload-images.jianshu.io/upload_images/2136918-b350c0e98ca47183?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)