Skip to content

Instantly share code, notes, and snippets.

@msymt
Last active June 27, 2022 09:05
Show Gist options
  • Select an option

  • Save msymt/acad5b4aa567dd7f2c0afe50f2e665a6 to your computer and use it in GitHub Desktop.

Select an option

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

msymt commented Jun 27, 2022

Copy link
Copy Markdown
Author

こっちの方が早い?

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

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