Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,7 @@
|
|||
with open('xxx.txt') as f:
|
||||
for i, line in enumerate(f):
|
||||
if i == 6:
|
||||
break
|
||||
else:
|
||||
print('Not 7 lines in file')
|
||||
line = None
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
from itertools import islice
|
||||
|
||||
with open('xxx.txt') as f:
|
||||
try:
|
||||
line = next(islice(f, 6, 7))
|
||||
except StopIteration:
|
||||
print('Not 7 lines in file')
|
||||
|
|
@ -0,0 +1 @@
|
|||
print open('xxx.txt').readlines()[:7][-1]
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
from itertools import islice
|
||||
|
||||
with open('xxx.txt') as f:
|
||||
linelist = list(islice(f, 7, 8))
|
||||
assert linelist != [], 'Not 7 lines in file'
|
||||
line = linelist[0]
|
||||
Loading…
Add table
Add a link
Reference in a new issue