Skip to content

Instantly share code, notes, and snippets.

@msymt
Last active June 27, 2022 09:05
Show Gist options
  • Save msymt/acad5b4aa567dd7f2c0afe50f2e665a6 to your computer and use it in GitHub Desktop.
Save msymt/acad5b4aa567dd7f2c0afe50f2e665a6 to your computer and use it in GitHub Desktop.
python上であるファイルの中身をoutputにリダイレクトしたいとき
import subprocess
# $cat input > output
subprocess.run(['cat'], stdin=open("input", 'r'), stdout=open("output", 'a'))
@msymt
Copy link
Author

msymt commented Jun 27, 2022

こっちの方が早い?

import shutil
shutil.copyfile("input", "output")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment