Skip to content

Instantly share code, notes, and snippets.

@takurx
Last active January 12, 2019 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takurx/0385fc15d9aecf5e3aacd2372e1429ca to your computer and use it in GitHub Desktop.
Save takurx/0385fc15d9aecf5e3aacd2372e1429ca to your computer and use it in GitHub Desktop.
無限にパイプ入力する(Ctrl+Cで止まるようにKeyboardInterruptを追加)
# example:
# echo "hogehoge" | python pipe_and_write.py
#
# ref. 1, http://d.hatena.ne.jp/thetama/20091103/1257213919
# ref. 2, https://qiita.com/keisuke-nakata/items/e77b123d75d4b52aac77
#
import sys
try:
while True:
inline = sys.stdin.readline()
sys.stdout.write(inline)
except KeyboardInterrupt:
print("KeyboardInterrupt")
pass
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment