Home > other >  O great god explain about python3 File. The problem of the seek function
O great god explain about python3 File. The problem of the seek function

Time:04-03

F=open (' aa. TXT ', 'rb +')
'0123456789 abcdef f.w rite (b)
F.s eek (1)

See the tutorial says the seek is positioning a pointer, parameter code from bottom is the file which is negative, but I this code error
F.s eek (1)
OSError: [22] Errno Invalid argument


Then I change the code
Import the random
F=open (' data. TXT ', 'w +')
For I in range (100000) :
F.w rite (STR (random randint (1100)) + '\ n')

F.s eek (1)
Print (f.r ead ())
F. lose ()

An error is as follows:
F.s eek (1)
ValueError: negative the seek position - 1


F.s eek (0) is no problem with negative has been to is wrong, please explain

CodePudding user response:

Is negative, is to open the file in binary mode

CodePudding user response:

F=open (' aa. TXT ', 'rb +) this is not a binary open
  • Related