Guest User

Untitled

a guest
Jun 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. >>> f = open(r"myfile.txt", "a+")
  2. >>> f.seek(-1,2)
  3. >>> f.read()
  4. 'a'
  5. >>> f.write('n')
  6.  
  7. Traceback (most recent call last):
  8. File "<stdin>", line 1, in <module>
  9. IOError: [Errno 0] Error
  10.  
  11. f.seek(f.tell())
  12.  
  13. >>> f = open("myfile.txt", "r+")
  14. >>> f.write('n')
  15.  
  16. $ echo hello > myfile.txt
  17. $ python
  18. Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
  19. [GCC 4.3.2] on linux2
  20. Type "help", "copyright", "credits" or "license" for more information.
  21. >>> f = open('myfile.txt', 'r+')
  22. >>> f.seek(-1, 2)
  23. >>> f.tell()
  24. 5L
  25. >>> f.read()
  26. 'n'
  27. >>> f.write('n')
  28. >>> f.close()
Add Comment
Please, Sign In to add comment