0

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

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – FLAK-ZOSO Jan 06 '22 at 10:01

1 Answers1

0

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:]
Den Avrondo
  • 89
  • 1
  • 6