Skip to content

Commit e92b70c

Browse files
author
guiyin.xiong
committed
watch vedio again
1 parent d15ee7a commit e92b70c

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.13

Python文件对象及os、os.path和pickle模块.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ open方法可以接收三个参数:文件名、模式和缓冲区参数;
2828
简单模式:
2929
r: 只读
3030
open('/var/log/message.log','r')
31-
r: 写入,从文件指针所在位置开始写入;
31+
w: 写入,从文件指针所在位置开始写入;
3232
a:附加,从文件尾部开始写入;
3333
在模式后使用"+"表示同时支持输入、输出操作;
3434
如:r+、w+和a+
@@ -41,7 +41,7 @@ open方法可以接收三个参数:文件名、模式和缓冲区参数;
4141
负数表示使用系统默认设置;
4242
正数表示使用近似指定大小的缓冲;
4343

44-
var_name = open(filename[mode,[bufsize]])
44+
var_name = open(filename,[mode,[bufsize]])
4545
```python
4646
mode:
4747
r

Python迭代器、列表解析及生成器.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ sys.getrefcount() 获取对象引用计数;
1212

1313
- 减少对象的引用次数:
1414
- 引用此对象的变量名被显式销毁: del x
15-
- 引用此对象的某变量名重新赋值
15+
- 给引用此对象的某变量名重新赋值
1616
- 从容器中移除对象时,类似list.pop()
17-
- 容器本身被销毁;容器中所有引用的对象的引用计数减少
17+
- 容器本身被销毁;容器中所有引用的对象的引用计数都会减少
1818

1919
2、if:
2020

@@ -34,7 +34,7 @@ while boolean_expression:
3434
while_suite
3535
if boolean_expression2: continue
3636
if boolean_expression3: break
37-
else:
37+
else: # 循环正常结束时,可执行一次的代码;
3838
else_suite
3939
```
4040
4、 for:
@@ -43,7 +43,7 @@ for expression in object:
4343
for_suit
4444
if boolean_expression2: continue
4545
if boolean_expression3: break
46-
else:
46+
else: # 循环正常结束时,可执行一次的代码;
4747
else_suite
4848
```
4949

@@ -63,6 +63,7 @@ x 123
6363
for in range(1,len(l1),2):
6464
print(l1[i])
6565
```
66+
6667
```python
6768
l1 = [1,3,4,6,9]
6869
l2 = [2,3,5,8,9]
@@ -73,7 +74,7 @@ for i in l1:
7374
l3.append(i)
7475
```
7576

76-
完备遍历:for。
77+
完备遍历:for。 使用for i in list: 遍历list中的每一个元素;
7778

7879
非完备遍历: 使用非完全索引的方式来遍历;
7980

@@ -88,6 +89,8 @@ iterable(可迭代)对象;
8889
序列类型:如:list,str,tuple
8990
非序列类型:如:dict,file
9091
用户自定义的一些包含了__iter__()或__getitem__()方法的类;
92+
93+
调用__iter____getitem__方法会在内存中生成一个可以迭代该对象中所有元素的迭代器,使用该迭代起的next方法可以逐个取得迭代器中的元素;直到元素结束,抛出异常;
9194
```
9295

9396
```python
@@ -145,7 +148,9 @@ In [61]: print(l2)
145148
[1, 4, 9, 16, 25]
146149
```
147150

148-
列表解析根据已有列表,高效生成新列表的方式就是列表解析;
151+
列表解析:
152+
153+
根据已有列表,高效生成新列表的方式就是列表解析;
149154
```python
150155
l3 = [i**2 for i in l1] # 比上述通过for完成的要高效;
151156

0 commit comments

Comments
 (0)