GeezerVison is showing github.com — 两点水 · dk2nd/Python@f856b62
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: python1/Introduction.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ Python 是著名的“龟叔” Guido van Rossum 在 1989 年圣诞节期间, | 6 | 6 |
| 7 | 7 | 这是 2017 年 2 月编程语言排行榜 TOP20 榜单: | 8 | 8 |
| 9 | | - | | 9 | + | 10 | 10 |
| 11 | 11 | 还有就是 Top 10 编程语言 TIOBE 指数走势: | 12 | 12 |
| @@ -20,4 +20,4 @@ Python 是高级编程语言,它有一个特点就是能快速的开发。Pyth | 20 | 20 |
| 21 | 21 | 第一个缺点就是运行速度慢,和C程序相比非常慢,因为Python是解释型语言,你的代码在执行时会一行一行地翻译成CPU能理解的机器码,这个翻译过程非常耗时,所以很慢。而C程序是运行前直接编译成CPU能执行的机器码,所以非常快。 | 22 | 22 |
| 23 | | -第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。 | | 23 | +第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。 |
Collapse file Copy file name to clipboardExpand all lines: python3/List.md +5-4Lines changed: 5 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -24,7 +24,8 @@ print(list1[0:2]) | 24 | 24 |
| 25 | 25 | 输出的结果: | 26 | 26 |
| 27 | | - | | 27 | + | | 28 | + | 28 | 29 |
| 29 | 30 | ## 3、更新 List(列表) ## | 30 | 31 |
| @@ -43,7 +44,7 @@ print(list1) | 43 | 44 |
| 44 | 45 | 输出的结果: | 45 | 46 |
| 46 | | - | | 47 | + | 47 | 48 |
| 48 | 49 |
| 49 | 50 | ## 4、删除 List(列表) ## | @@ -60,7 +61,7 @@ print(list1) | 60 | 61 |
| 61 | 62 | 输出的结果: | 62 | 63 |
| 63 | | - | | 64 | + | 64 | 65 |
| 65 | 66 | ## 5、List(列表)运算符 ## | 66 | 67 |
| @@ -154,4 +155,4 @@ print(newUser) | 154 | 155 |
| 155 | 156 | ``` | 156 | 157 |
| 157 | | - | | 158 | + |
Collapse file Copy file name to clipboardExpand all lines: python3/Preface.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 |
| 5 | 5 | # 目录 # | 6 | 6 |
| 7 | | - | | 7 | + |
Collapse file Copy file name to clipboardExpand all lines: python3/tuple.md +5-4Lines changed: 5 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,9 +25,10 @@ tuple3=() | 25 | 25 | tuple4=(123,) | 26 | 26 | ``` | 27 | 27 |
| 28 | | -如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple,又可以表示数学公式中的小括号,这就产生了歧义,因此,Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值 | | 28 | +如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple,又可以表示数学公式中的小括号,这就产生了歧义,因此,Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值 | | 29 | + | | 30 | + | 29 | 31 |
| 30 | | - | 31 | 32 |
| 32 | 33 |
| 33 | 34 | ## 2、tuple(元组)的索引 ## | @@ -50,7 +51,7 @@ print(tuple2[0]) | 50 | 51 |
| 51 | 52 | 输出的结果: | 52 | 53 |
| 53 | | - | | 54 | + | 54 | 55 |
| 55 | 56 | ## 4、修改 tuple (元组) ## | 56 | 57 |
| @@ -114,4 +115,4 @@ del tuple1 | 114 | 115 | |len(tuple)|计算元组元素个数| | 115 | 116 | |max(tuple)|返回元组中元素最大值| | 116 | 117 | |min(tuple)|返回元组中元素最小值| | 117 | | -|tuple(seq)|将列表转换为元组| | | 118 | +|tuple(seq)|将列表转换为元组| |
Collapse file Copy file name to clipboardExpand all lines: python4/Preface.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 |
| 5 | 5 | # 目录 # | 6 | 6 |
| 7 | | - | | 7 | + |
Collapse file Copy file name to clipboardExpand all lines: python4/Set.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -79,7 +79,7 @@ print(set1) | 79 | 79 |
| 80 | 80 | 因为 set 是一个无序不重复元素集,因此,两个 set 可以做数学意义上的 union(并集), intersection(交集), difference(差集) 等操作。 | 81 | 81 |
| 82 | | - | | 82 | + | 83 | 83 |
| 84 | 84 | 例子: | 85 | 85 |
| |
Collapse file Copy file name to clipboardExpand all lines: python5/Cycle.md +7-7Lines changed: 7 additions & 7 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 |
| 5 | 5 | 循环语句的一般形式如下: | 6 | 6 |
| 7 | | - | | 7 | + | 8 | 8 |
| 9 | 9 | Python 提供了 for 循环和 while 循环,当然还有一些控制循环的语句: | 10 | 10 |
| @@ -19,7 +19,7 @@ Python 提供了 for 循环和 while 循环,当然还有一些控制循环的 | 19 | 19 |
| 20 | 20 |
| 21 | 21 | ```python | 22 | | -count = 1 | | 22 | +count = 1 | 23 | 23 | sum = 0 | 24 | 24 | while (count <= 100): | 25 | 25 | sum = sum + count | @@ -38,7 +38,7 @@ print(sum) | 38 | 38 | 比如,上面的例子是计算 1 到 100 所有整数的和,当我们需要判断 sum 大于 1000 的时候,不在相加时,可以用到 break ,退出整个循环 | 39 | 39 |
| 40 | 40 | ```python | 41 | | -count = 1 | | 41 | +count = 1 | 42 | 42 | sum = 0 | 43 | 43 | while (count <= 100): | 44 | 44 | sum = sum + count | @@ -57,7 +57,7 @@ print(sum) | 57 | 57 | 有时候,我们只想统计 1 到 100 之间的奇数和,那么也就是说当 count 是偶数,也就是双数的时候,我们需要跳出当次的循环,不想加,这时候可以用到 break | 58 | 58 |
| 59 | 59 | ```python | 60 | | -count = 1 | | 60 | +count = 1 | 61 | 61 | sum = 0 | 62 | 62 | while (count <= 100): | 63 | 63 | if ( count % 2 == 0): # 双数时跳过输出 | @@ -105,13 +105,13 @@ else: | 105 | 105 | 它的流程图基本如下: | 106 | 106 |
| 107 | 107 |
| 108 | | - | | 108 | + | 109 | 109 |
| 110 | 110 | 基本的语法格式: | 111 | 111 |
| 112 | 112 | ```python | 113 | 113 | for iterating_var in sequence: | 114 | | - statements(s) | | 114 | + statements(s) | 115 | 115 | ``` | 116 | 116 |
| 117 | 117 | 实例: | | 129 | 129 | l | 130 | 130 | l | 131 | 131 | o | 132 | | - | | 132 | +
| 133 | 133 | 两 | 134 | 134 | 点 | 135 | 135 | 水 | |
Collapse file Copy file name to clipboardExpand all lines: python5/If.md +3-3Lines changed: 3 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ Python 程序语言指定任何非 0 和非空(null)值为 True,0 或者 n | 6 | 6 |
| 7 | 7 | 执行的流程图如下: | 8 | 8 |
| 9 | | - | | 9 | + | 10 | 10 |
| 11 | 11 | ## 1、if 语句的基本形式 ## | 12 | 12 |
| | 46 | 46 | 上面也说道,非零数值、非空字符串、非空 list 等,判断为True,否则为False。因此也可以这样写: | 47 | 47 |
| 48 | 48 | ```python | 49 | | -num = 6 | | 49 | +num = 6 | 50 | 50 | if num : | 51 | 51 | print('Hello Python') | 52 | 52 | ``` | @@ -111,7 +111,7 @@ else : | 111 | 111 |
| 112 | 112 | if ( java >= 80 and java < 90 ) or ( python >= 80 and python < 90): | 113 | 113 | print('良好') | 114 | | - | | 114 | + | 115 | 115 | ``` | 116 | 116 |
| 117 | 117 | 输出结果: | |
Collapse file Copy file name to clipboardExpand all lines: python5/Preface.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | 第一次建学习群,而且是 Python 的学习群,虽然之前深入学习和工作都是 Android 相关的,最近学起来 Python ,真的很好玩,所以创了个微信群,希望童鞋们进群学习讨论。也可以直接加我微`androidwed`拉进群。也欢迎大家在 [Gitbook](https://www.readwithu.com/) 中提出文章的不足。 | 4 | 4 |
| 5 | | - | | 5 | + | 6 | 6 |
| 7 | 7 |
| 8 | 8 | # 目录 # | 9 | 9 |
| 10 | | - | | 10 | + |
Collapse file Copy file name to clipboardExpand all lines: python6/2.md +4-4Lines changed: 4 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,7 @@ def chagne_number( b ): | 9 | 9 |
| 10 | 10 | b = 1 | 11 | 11 | chagne_number(b) | 12 | | -print( b ) | | 12 | +print( b ) | 13 | 13 | ``` | 14 | 14 |
| 15 | 15 | 最后输出的结果为: | @@ -31,7 +31,7 @@ print( b ) | 31 | 31 |
| 32 | 32 | **可更改的类型**:变量赋值 `a = [1,2,3,4,5,6]` ,就是生成一个对象 list ,list 里面有 6 个元素,而变量 a 指向 list ,`a[2] = 5`则是将 list a 的第三个元素值更改,这里跟上面是不同的,并不是将 a 重新指向,而是直接修改 list 中的元素值。 | 33 | 33 |
| 34 | | - | | 34 | + | 35 | 35 |
| 36 | 36 | 这也将影响到函数中参数的传递了: | 37 | 37 |
| @@ -47,7 +47,7 @@ def chagne_number( b ): | 47 | 47 | print('函数中一开始 b 的值:{}' .format( b ) ) | 48 | 48 | b = 1000 | 49 | 49 | print('函数中 b 赋值后的值:{}' .format( b ) ) | 50 | | - | | 50 | + | 51 | 51 |
| 52 | 52 | b = 1 | 53 | 53 | chagne_number( b ) | @@ -73,7 +73,7 @@ def chagne_list( b ): | 73 | 73 | print('函数中一开始 b 的值:{}' .format( b ) ) | 74 | 74 | b.append(1000) | 75 | 75 | print('函数中 b 赋值后的值:{}' .format( b ) ) | 76 | | - | | 76 | + | 77 | 77 |
| 78 | 78 | b = [1,2,3,4,5] | 79 | 79 | chagne_list( b ) | |
|