【发布时间】:2018-01-31 23:53:59
【问题描述】:
我在 LiClipse(Eclipse) 中遇到了这个脚本的问题
import stdio
import stddraw
# Read x and y scales from standard input, and configure standard
# draw accordingly. Then read points from standard input until
# end-of-file, and plot them on standard draw.
x0 = stdio.readFloat()
y0 = stdio.readFloat()
x1 = stdio.readFloat()
y1 = stdio.readFloat()
stddraw.setXscale(x0, x1)
stddraw.setYscale(y0, y1)
# Read and plot the points.
stddraw.setPenRadius(0.0)
while not stdio.isEmpty():
x = stdio.readFloat()
y = stdio.readFloat()
stddraw.point(x, y)
stddraw.show()
我在“运行配置”中使用this file 作为“输入文件”。
我得到一个没有响应的黑色 stddraw 窗口。 如果我在 LiClipse 控制台中输入“Ctrl-Z”,有时会得到结果。
我已经在调试器中运行了这个脚本 - 它在 stdio.py 的行上停止(使用运算符“line = sys.stdin.readline()”) usa.txt 的最后一行。
我已经在 Geany 中运行过这个文件——它可以工作!
这是 PyDeve (Eclipse) 中的错误吗?
谢谢!
【问题讨论】:
-
readFloat是否在每行末尾使用换行符? -
对了,你可以试试
while stdio.hasNextLine() -
我在终端中运行这个脚本(“python plotfilter.py
-
Eclipse 只模拟一个实际的终端。同样,我不认为您正在使用不可见的换行符,因此它一直在等待读取浮点数
-
我在调试器中看到,该脚本读取所有浮点数,除了最后一行。标准输出库:introcs.cs.princeton.edu/python/code/stdio.py
标签: python eclipse stdin pydev liclipse