簡単なコードを見てみましょう:
import os
f = open('test.bin', 'wb')
f.write('X')
f.close()
# test.bin - X
f = open('test.bin', 'r+b')
f.seek(0, os.SEEK_END)
f.write('AB')
# test.bin - XAB
f.seek(0, os.SEEK_SET)
f.write('Y')
# test.bin - YAB
print f.read(1)
# test.bin - YBB and prints B 0_o whhyyy?
f.close()
その場合、なぜ read メソッドは write のように機能するのですか??
公式サイトからの Windows ダウンロードには Python 2.5 と 2.7 を使用しています。