Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Introducing StringIO
- # script converts string into a file object
- import StringIO
- contents="gaurav is a bad boy"
- ssock=StringIO.StringIO(contents)
- print ssock.read()
- # Now nothing will be printed
- print ssock.read()
- # seek the file
- ssock.seek(0)
- # now read 15 characters
- print ssock.read(15)
- ssock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement