python dropwhile跳过开头的几行
- 2019 年 10 月 11 日
- 筆記
from itertools import dropwhile with open('/etc/passwd') as f: ... for line in dropwhile(lambda line: line.startswith('#'), f): ... print(line, end='') from itertools import islice items = ['a', 'b', 'c', 1, 4, 10, 15] for x in islice(items, 3, None): ... print(x) ... 1 4 10 15