Simple Sand Samples |
Python > バイナリデータをファイルへ書き込む
write-bin.py
import sys f=open(sys.argv[1] , "wb") f.write("\1") f.write("\2") f.write("\3") f.close()
$ python write-bin.py hoge.bin
$ od -tx1 hoge.bin
0000000 01 02 03
0000003
$
$ od -tx1 hoge.bin
0000000 01 02 03
0000003
$