【发布时间】:2016-10-06 03:16:12
【问题描述】:
我有以下代码每 3 秒打开/关闭一个插座。
start_time = time.time()
counter = 0
agent = snmpy4.Agent("192.168.9.50")
while True:
if (counter % 2 == 0):
agent.set("1.3.6.1.4.1.13742.6.4.1.2.1.2.1.1",1)
else:
agent.set("1.3.6.1.4.1.13742.6.4.1.2.1.2.1.1", 0)
time.sleep(3- ((time.time()-start_time) % 3))
counter = counter + 1
如果输入某些内容(例如空格),是否可以让循环在任何给定点终止......同时让上面的代码同时运行
【问题讨论】:
-
目标操作系统是什么?
-
@PatrickHaugh 我在 windows os (7) 上运行它
-
在此处查看使用 msvcrt stackoverflow.com/questions/20576960/… 的其他可能解决方案和示例