Last active
August 28, 2018 13:37
-
-
Save bonprosoft/d7a365f6e024233bfbaac683e11cd033 to your computer and use it in GitHub Desktop.
sys.stdinの挙動の違い
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
import sys | |
for x in sys.stdin: | |
sys.stdout.write('stdin: {}'.format(x)) | |
sys.stdout.flush() | |
"""Output. | |
[py36] | |
hoge | |
stdin: hoge | |
fuga | |
stdin: fuga | |
^D | |
[py27] | |
hoge | |
stdin: hoge | |
fuga | |
stdin: fuga | |
^D | |
""" |
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
import sys | |
for x in sys.stdin: | |
sys.stdout.write('stdin: {}'.format(x)) | |
sys.stdout.flush() | |
"""Output. | |
[py36] | |
hoge | |
stdin: hoge | |
fuga | |
stdin: fuga | |
^D | |
[py27] | |
hoge | |
fuga | |
^D | |
stdin: hoge | |
stdin: fuga | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment