这不会崩溃:
import sys
print(len(sys.stdin.read()))
input('lol')
但这会崩溃:
2300
lolTraceback (most recent call last):
File "test018.py",line 3,in <module>
input('lol')
EOFError: EOF when reading a line
有输出
cat somefile | myscript
问题:
- 为什么?
- 如何正确执行?我的目标是从STDIN中读取一些数据(例如
hey,does this look right?
),然后在某些问题上提示用户(例如{{1}})。