0
0

引数のファイルを結合する(バイナリで)

Posted at

Python の練習

#!/usr/bin/python3
import sys

if len(sys.argv) < 3:
    raise Exception("arguments too short")

# 最初の引数は自分自身なので削除
sys.argv.pop(0)

# 最後の引数は出力ファイル(残りは結合したいファイル)
writefile = sys.argv.pop(-1)

with open(writefile, "wb") as w:
    for arg in sys.argv:
        with open(arg, "rb") as r:
            w.write(r.read())
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0