Skip to content

Commit f856b62

Browse files
committed
两点水
1 parent 1b69364 commit f856b62

File tree

14 files changed

+42
-40
lines changed

14 files changed

+42
-40
lines changed

python1/Introduction.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Python 是著名的“龟叔” Guido van Rossum 在 1989 年圣诞节期间,
66

77
这是 2017 年 2 月编程语言排行榜 TOP20 榜单:
88

9-
![2 月编程语言排行榜 TOP20 榜单.png](https://user-gold-cdn.xitu.io/2017/6/18/1ed5d77b644cdd252699e7b2bfd772c5)
9+
![2 月编程语言排行榜 TOP20 榜单.png](http://upload-images.jianshu.io/upload_images/2136918-f7fc786f001cbfc0?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
1010

1111
还有就是 Top 10 编程语言 TIOBE 指数走势:
1212

@@ -20,4 +20,4 @@ Python 是高级编程语言,它有一个特点就是能快速的开发。Pyth
2020

2121
第一个缺点就是运行速度慢,和C程序相比非常慢,因为Python是解释型语言,你的代码在执行时会一行一行地翻译成CPU能理解的机器码,这个翻译过程非常耗时,所以很慢。而C程序是运行前直接编译成CPU能执行的机器码,所以非常快。
2222

23-
第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。
23+
第二个缺点就是代码不能加密。如果要发布你的 Python 程序,实际上就是发布源代码。像 JAVA , C 这些编译型的语言,都没有这个问题,而解释型的语言,则必须把源码发布出去。

python3/List.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ print(list1[0:2])
2424

2525
输出的结果:
2626

27-
![访问 List(列表)中的值](https://user-gold-cdn.xitu.io/2017/6/21/eb8c85eb2cfccc112dbb891536014113)
27+
![访问 List(列表)中的值](http://upload-images.jianshu.io/upload_images/2136918-ab562ada6ba08848?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
28+
2829

2930
## 3、更新 List(列表) ##
3031

@@ -43,7 +44,7 @@ print(list1)
4344

4445
输出的结果:
4546

46-
![更新 List(列表)](https://user-gold-cdn.xitu.io/2017/6/21/286bf8a5953d10aada532eb3d2909921)
47+
![更新 List(列表)](http://upload-images.jianshu.io/upload_images/2136918-96de950da2563ac6?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
4748

4849

4950
## 4、删除 List(列表) ##
@@ -60,7 +61,7 @@ print(list1)
6061

6162
输出的结果:
6263

63-
![删除 List(列表)](https://user-gold-cdn.xitu.io/2017/6/21/a2858b1cc9af6e02527119080a98b6a8)
64+
![删除 List(列表)](http://upload-images.jianshu.io/upload_images/2136918-e761bf56f583089f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
6465

6566
## 5、List(列表)运算符 ##
6667

@@ -154,4 +155,4 @@ print(newUser)
154155

155156
```
156157

157-
![list的使用](https://dn-mhke0kuv.qbox.me/529c1895edddaad61deb.png)
158+
![list的使用](http://upload-images.jianshu.io/upload_images/2136918-65d31cae9f8bb34d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

python3/Preface.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
# 目录 #
66

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

python3/tuple.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ tuple3=()
2525
tuple4=(123,)
2626
```
2727

28-
如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple,又可以表示数学公式中的小括号,这就产生了歧义,因此,Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值
28+
如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple,又可以表示数学公式中的小括号,这就产生了歧义,因此,Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值
29+
30+
![创建tuple](http://upload-images.jianshu.io/upload_images/2136918-2072470ffe7cbee7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2931

30-
![创建tuple](https://dn-mhke0kuv.qbox.me/f4b7a62091fb5d4f206f.png)
3132

3233

3334
## 2、tuple(元组)的索引 ##
@@ -50,7 +51,7 @@ print(tuple2[0])
5051

5152
输出的结果:
5253

53-
![访问 tuple](https://dn-mhke0kuv.qbox.me/72844216bda8bc3e4a4b.png)
54+
![访问 tuple](http://upload-images.jianshu.io/upload_images/2136918-edfb7c9ebc7d5ab0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
5455

5556
## 4、修改 tuple (元组) ##
5657

@@ -114,4 +115,4 @@ del tuple1
114115
|len(tuple)|计算元组元素个数|
115116
|max(tuple)|返回元组中元素最大值|
116117
|min(tuple)|返回元组中元素最小值|
117-
|tuple(seq)|将列表转换为元组|
118+
|tuple(seq)|将列表转换为元组|

python4/Preface.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
# 目录 #
66

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

python4/Set.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ print(set1)
7979

8080
因为 set 是一个无序不重复元素集,因此,两个 set 可以做数学意义上的 union(并集), intersection(交集), difference(差集) 等操作。
8181

82-
![set集合运算](https://user-gold-cdn.xitu.io/2017/6/23/9afd2a3081e9d618cc55bf859b545d12)
82+
![set集合运算](http://upload-images.jianshu.io/upload_images/2136918-733b1d1071f772bd?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
8383

8484
例子:
8585

python5/Cycle.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
循环语句的一般形式如下:
66

7-
![python循环语句](https://user-gold-cdn.xitu.io/2017/6/23/d0761ec24b83fea3d7008c29074ba5cb)
7+
![python循环语句](http://upload-images.jianshu.io/upload_images/2136918-eaaae2fbfec3330f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
88

99
Python 提供了 for 循环和 while 循环,当然还有一些控制循环的语句:
1010

@@ -19,7 +19,7 @@ Python 提供了 for 循环和 while 循环,当然还有一些控制循环的
1919

2020

2121
```python
22-
count = 1
22+
count = 1
2323
sum = 0
2424
while (count <= 100):
2525
sum = sum + count
@@ -38,7 +38,7 @@ print(sum)
3838
比如,上面的例子是计算 1 到 100 所有整数的和,当我们需要判断 sum 大于 1000 的时候,不在相加时,可以用到 break ,退出整个循环
3939

4040
```python
41-
count = 1
41+
count = 1
4242
sum = 0
4343
while (count <= 100):
4444
sum = sum + count
@@ -57,7 +57,7 @@ print(sum)
5757
有时候,我们只想统计 1 到 100 之间的奇数和,那么也就是说当 count 是偶数,也就是双数的时候,我们需要跳出当次的循环,不想加,这时候可以用到 break
5858

5959
```python
60-
count = 1
60+
count = 1
6161
sum = 0
6262
while (count <= 100):
6363
if ( count % 2 == 0): # 双数时跳过输出
@@ -105,13 +105,13 @@ else:
105105
它的流程图基本如下:
106106

107107

108-
![for循环的流程图](https://user-gold-cdn.xitu.io/2017/6/26/235ff5c72862b213486e0bf23852a245)
108+
![for循环的流程图](http://upload-images.jianshu.io/upload_images/2136918-a0728c1c488238af?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
109109

110110
基本的语法格式:
111111

112112
```python
113113
for iterating_var in sequence:
114-
statements(s)
114+
statements(s)
115115
```
116116

117117
实例:
@@ -129,7 +129,7 @@ e
129129
l
130130
l
131131
o
132-
132+
133133
134134
135135

python5/If.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Python 程序语言指定任何非 0 和非空(null)值为 True,0 或者 n
66

77
执行的流程图如下:
88

9-
![if语句流程图](https://user-gold-cdn.xitu.io/2017/6/23/9b796437c2f0ac3ba1dc5009de091031)
9+
![if语句流程图](http://upload-images.jianshu.io/upload_images/2136918-4ee2486190450a1a?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
1010

1111
## 1、if 语句的基本形式 ##
1212

@@ -46,7 +46,7 @@ else :
4646
上面也说道,非零数值、非空字符串、非空 list 等,判断为True,否则为False。因此也可以这样写:
4747

4848
```python
49-
num = 6
49+
num = 6
5050
if num :
5151
print('Hello Python')
5252
```
@@ -111,7 +111,7 @@ else :
111111

112112
if ( java >= 80 and java < 90 ) or ( python >= 80 and python < 90):
113113
print('良好')
114-
114+
115115
```
116116

117117
输出结果:

python5/Preface.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
第一次建学习群,而且是 Python 的学习群,虽然之前深入学习和工作都是 Android 相关的,最近学起来 Python ,真的很好玩,所以创了个微信群,希望童鞋们进群学习讨论。也可以直接加我微`androidwed`拉进群。也欢迎大家在 [Gitbook](https://www.readwithu.com/) 中提出文章的不足。
44

5-
![Python学习群](https://user-gold-cdn.xitu.io/2017/6/27/aaeb2c5817779cef45fee80bf544ff30)
5+
![Python学习群](http://upload-images.jianshu.io/upload_images/2136918-f3f0c60ce12e5a92?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
66

77

88
# 目录 #
99

10-
![草根学Python(五) 条件语句和循环语句](https://user-gold-cdn.xitu.io/2017/6/27/b09d98a2f40724326f8b04b2049236b5)
10+
![草根学Python(五) 条件语句和循环语句](http://upload-images.jianshu.io/upload_images/2136918-32902eec93d9ffc1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

python6/2.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def chagne_number( b ):
99

1010
b = 1
1111
chagne_number(b)
12-
print( b )
12+
print( b )
1313
```
1414

1515
最后输出的结果为:
@@ -31,7 +31,7 @@ print( b )
3131

3232
**可更改的类型**:变量赋值 `a = [1,2,3,4,5,6]` ,就是生成一个对象 list ,list 里面有 6 个元素,而变量 a 指向 list ,`a[2] = 5`则是将 list a 的第三个元素值更改,这里跟上面是不同的,并不是将 a 重新指向,而是直接修改 list 中的元素值。
3333

34-
![指向问题](https://user-gold-cdn.xitu.io/2017/6/27/d23fb1478065a0bcc19949cfbc88c5a0)
34+
![指向问题](http://upload-images.jianshu.io/upload_images/2136918-31b1031d75e1cec9?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
3535

3636
这也将影响到函数中参数的传递了:
3737

@@ -47,7 +47,7 @@ def chagne_number( b ):
4747
print('函数中一开始 b 的值:{}' .format( b ) )
4848
b = 1000
4949
print('函数中 b 赋值后的值:{}' .format( b ) )
50-
50+
5151

5252
b = 1
5353
chagne_number( b )
@@ -73,7 +73,7 @@ def chagne_list( b ):
7373
print('函数中一开始 b 的值:{}' .format( b ) )
7474
b.append(1000)
7575
print('函数中 b 赋值后的值:{}' .format( b ) )
76-
76+
7777

7878
b = [1,2,3,4,5]
7979
chagne_list( b )

python6/3.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ print(sum(1,2))
2424

2525
这个示例,还通过内置函数`isinstance()`进行数据类型检查,检查调用函数时参数是否是整形和浮点型。如果参数类型不对,会报错,提示 `参数类型错误`,如图:
2626

27-
![检查函数参数是否正确](https://user-gold-cdn.xitu.io/2017/6/28/d844f6a7b80370797dfea8f251f2a709)
27+
![检查函数参数是否正确](http://upload-images.jianshu.io/upload_images/2136918-cfe5907d67e912d8?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2828

2929
当然,函数也可以返回多个值,具体实例如下:
3030

@@ -35,7 +35,7 @@ def division ( num1, num2 ):
3535
# 求商与余数
3636
a = num1 % num2
3737
b = (num1-a) / num2
38-
return b , a
38+
return b , a
3939

4040
num1 , num2 = division(9,4)
4141
tuple1 = division(9,4)
@@ -51,4 +51,4 @@ print (tuple1)
5151
(2.0, 1)
5252
```
5353

54-
认真观察就可以发现,尽管从第一个输出值来看,返回了多个值,实际上是先创建了一个元组然后返回的。回忆一下,元组是可以直接用逗号来创建的,观察例子中的 ruturn ,可以发现实际上我们使用的是逗号来生成一个元组。
54+
认真观察就可以发现,尽管从第一个输出值来看,返回了多个值,实际上是先创建了一个元组然后返回的。回忆一下,元组是可以直接用逗号来创建的,观察例子中的 ruturn ,可以发现实际上我们使用的是逗号来生成一个元组。

python6/Preface.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
# 目录 #
66

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

python7/4.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def my_function():
6565
for i in range(10):
6666
print ( i )
6767

68-
my_function()
68+
my_function()
6969
```
7070

7171
输出的结果:
@@ -91,7 +91,7 @@ def my_function():
9191
for i in range(10):
9292
yield i
9393

94-
print(my_function())
94+
print(my_function())
9595
```
9696

9797
输出的结果:
@@ -119,7 +119,7 @@ for x in fibon(1000000):
119119

120120
运行的效果:
121121

122-
![计算斐波那契数列的生成器](https://user-gold-cdn.xitu.io/2017/7/2/7b45fa54beb097a3037954b85a9a4d99)
122+
![计算斐波那契数列的生成器](http://upload-images.jianshu.io/upload_images/2136918-304e50af22b787ce?imageMogr2/auto-orient/strip)
123123

124124
你看,运行一个这么打的参数,也不会说有卡死的状态,因为这种方式不会使用太大的资源。这里,最难理解的就是 generator 和函数的执行流程不一样。函数是顺序执行,遇到 return 语句或者最后一行函数语句就返回。而变成 generator 的函数,在每次调用 next() 的时候执行,遇到 yield语句返回,再次执行时从上次返回的 yield 语句处继续执行。
125125

@@ -136,9 +136,9 @@ def odd():
136136
yield ( 5 )
137137

138138
o = odd()
139-
print( next( o ) )
140-
print( next( o ) )
141-
print( next( o ) )
139+
print( next( o ) )
140+
print( next( o ) )
141+
print( next( o ) )
142142
```
143143

144144
输出的结果:

python7/Preface.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
# 目录 #
66

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

0 commit comments

Comments
 (0)