Last active
January 12, 2019 10:48
-
-
Save takurx/0385fc15d9aecf5e3aacd2372e1429ca to your computer and use it in GitHub Desktop.
無限にパイプ入力する(Ctrl+Cで止まるようにKeyboardInterruptを追加)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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