seek - Read specific bytes of file in python -


i want specify offset , read bytes of file

offset = 5 read(5)  

and read next 6-10 etc. read seek cannot understand how works , examples arent descriptive enough.

seek(offset,1) returns what?

thanks

just play python's repl see yourself:

[...]:/tmp$ cat hello.txt  hello world [...]:/tmp$ python python 2.7.6 (default, mar 22 2014, 22:59:56)  [gcc 4.8.2] on linux2 type "help", "copyright", "credits" or "license" more information. >>> f = open('hello.txt', 'rb') >>> f.seek(6, 1)    # move file pointer forward 6 bytes (i.e. 'w') >>> f.read()        # read rest of file current file pointer 'world\n' 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -