如何将多行作为输入传递给stdin(Python)
假设示例输入为:如何将多行作为输入传递给stdin(Python),python,eclipse,stdout,stdin,Python,Eclipse,Stdout,Stdin,假设示例输入为: "1 2 3" "hello" "hi there" "x y z" "5 6 7" 这应该被传递到stdin,输出应该只是将它们打印到stdout 我在sample.py中有以下代码,并且我使用Eclipse作为我的IDE import fileinput for line in fileinput.input(): print line 如果我使用命令行,我可能可以执行以下操作 python sample.py "1 2 3 \n hello" 将输入传递到
"1 2 3"
"hello"
"hi there"
"x y z"
"5 6 7"
这应该被传递到stdin,输出应该只是将它们打印到stdout
我在sample.py中有以下代码,并且我使用Eclipse作为我的IDE
import fileinput
for line in fileinput.input():
print line
如果我使用命令行,我可能可以执行以下操作
python sample.py "1 2 3 \n hello"
将输入传递到标准输入。但是我应该如何在Eclipse上做到这一点(当有多行代码应该输入到stdin中时)
因为我不知道怎么做,我只是把这些行放到一个txt文件中并从中读取。在Windows上
cmd
python sample.py
stdout
中得到一个输出 在Windows上
cmd
python sample.py
stdout
中得到一个输出