File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,15 @@ def get_lines():
294
294
for i in f:
295
295
yield i
296
296
```
297
+ 个人认为:还是设置下每次返回的行数较好,否则读取次数太多。
298
+ ```
299
+ def get_lines():
300
+ l = []
301
+ with open('file.txt','rb') as f:
302
+ data = f.readlines(60000)
303
+ l.append(data)
304
+ yield l
305
+ ```
297
306
Pandaaaa906提供的方法
298
307
``` python
299
308
from mmap import mmap
@@ -355,6 +364,7 @@ print(alist)
355
364
``` python
356
365
sorted (d.items(),key = lambda x :x[1 ])
357
366
```
367
+ x[0]代表用key进行排序;x[1]代表用value进行排序。
358
368
### 6.字典推导式
359
369
``` python
360
370
d = {key:value for (key,value) in iterable}
@@ -443,6 +453,10 @@ c. Python2里面继承object的是新式类,没有写父类的是经典类
443
453
444
454
d. 经典类目前在Python里基本没有应用
445
455
456
+ e. 保持class与type的统一对新式类的实例执行a.__ class__ 与type(a)的结果是一致的,对于旧式类来说就不一样了。
457
+
458
+ f.对于多重继承的属性搜索顺序不一样新式类是采用广度优先搜索,旧式类采用深度优先搜索。
459
+
446
460
### 16.python中内置的数据结构有几种?
447
461
a. 整型 int、 长整型 long、浮点型 float、 复数 complex
448
462
You can’t perform that action at this time.
0 commit comments