Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> f = open(r"myfile.txt", "a+")
- >>> f.seek(-1,2)
- >>> f.read()
- 'a'
- >>> f.write('n')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- IOError: [Errno 0] Error
- f.seek(f.tell())
- >>> f = open("myfile.txt", "r+")
- >>> f.write('n')
- $ echo hello > myfile.txt
- $ python
- Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
- [GCC 4.3.2] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> f = open('myfile.txt', 'r+')
- >>> f.seek(-1, 2)
- >>> f.tell()
- 5L
- >>> f.read()
- 'n'
- >>> f.write('n')
- >>> f.close()
Add Comment
Please, Sign In to add comment