seek operation in python

John Gordon gordon at panix.com
Wed Apr 29 14:53:21 EDT 2015


In <8b2bd328-08a6-4211-85c4-8d117d1aae1e at googlegroups.com> siva sankari R <buddingrose11 at gmail.com> writes:

> file=open("input","r")
> line=file.seek(7)
> print line

> The above code is supposed to print a line but it prints "none".
> I don't know where the mistake is. Help.!

The seek() function doesn't return any data; it just relocates the file
pointer.  You still have to do a read operation to get data from the
new location.

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gordon at panix.com    watch 'House', or a real serial killer to watch 'Dexter'.




More information about the Python-list mailing list