我有一个简单的代码块,可以在Windows 7机器和Ubuntu机器上完美运行,但是当我尝试在8.1 / 10上运行它时会冻结。我不确定为什么。我已经尝试过代码变体的3.0 / 3.6 / 2.7解释器,但它仍然冻结。有没有人有办法解决吗?违规代码是底部的if / else语句。
from graphics import *
def main():
lowx = -10.0
highx = +10.0
lowy = -10.0
highy = +10.0
incx = 0.1
points = []
x = lowx
while x <= highx:
# y = EvaluatePostfix(postfix, x)
if x > 0:
y = x * x
else:
y = x * x * x
points.append((x, y))
x += incx
# Graph
win = GraphWin("My Graphing Calculator", 700, 700)
win.setCoords(lowx, lowy, highx, highy)
for i in range(len(points) - 1):
p1 = Point(points[i][0], points[i][1])
p2 = Point(points[i + 1][0], points[i + 1][1])
line = Line(p1, p2)
line.draw(win)
while (True):
user = input("type your answer")
if user == "hello":
print("there")
else:
print("bad")
win.getMouse() # Pause to view result
win.close() # Close window when done
main()