instead on writing can we write this in one command
`f=open('spiderman.txt','w') f.seek(2) f.read()'
The seek and read command
instead on writing can we write this in one command
`f=open('spiderman.txt','w') f.seek(2) f.read()'
The seek and read command
Firstly, you must change mode to reading by removing 'w'
argument, that opens your file for writing.
with open('spiderman.txt') as f:
f.seek(2)
text = f.read()
Secondly, you can use slices to cut off your text (Understanding slice notation)
with open('spiderman.txt') as f:
text = f.read()[2:]