1
假设我编写了这样的程序。如何在不停止程序的情况下更改参数
# run the program until the user gives a "stop" input
usrinpt=""`
n=1
while usrinpt!="stop":
n+=1
---- do-something -----
---- do-something -----
---- do-something -----
print n # print the number of loops it has gone through.
现在程序将运行,直到我手动将参数usrinpt
更改为“stop”。但是使用raw_input会在每一步都停止模拟,这不是我想要的。
那么,有没有办法在不停止仿真的情况下更改usrinpt
?
这肯定会工作,但有没有办法做到这一点,而不使用中断 –