Skip to content

Commit 52e021a

Browse files
committed
huge file
1 parent 9449e5a commit 52e021a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ def get_lines():
294294
for i in f:
295295
yield i
296296
```
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+
```
297306
Pandaaaa906提供的方法
298307
```python
299308
from mmap import mmap
@@ -355,6 +364,7 @@ print(alist)
355364
```python
356365
sorted(d.items(),key=lambda x:x[1])
357366
```
367+
x[0]代表用key进行排序;x[1]代表用value进行排序。
358368
### 6.字典推导式
359369
```python
360370
d = {key:value for (key,value) in iterable}
@@ -443,6 +453,10 @@ c. Python2里面继承object的是新式类,没有写父类的是经典类
443453

444454
d. 经典类目前在Python里基本没有应用
445455

456+
e. 保持class与type的统一对新式类的实例执行a.__class__与type(a)的结果是一致的,对于旧式类来说就不一样了。
457+
458+
f.对于多重继承的属性搜索顺序不一样新式类是采用广度优先搜索,旧式类采用深度优先搜索。
459+
446460
### 16.python中内置的数据结构有几种?
447461
a. 整型 int、 长整型 long、浮点型 float、 复数 complex
448462

0 commit comments

Comments
 (0)