我正在运行下面的代码。从终端我把python test.py
. 但它什么也没给我。
###test.py### Version 2
from threading import Timer
def hello():
print "Hello"
t=Timer(5, hello)
t.start()
我在另一台机器上尝试了相同的代码,它正确地向我显示了输出。我试着一步一步来。我只保留了print
声明,它工作正常。然后我将该 print 添加到一个函数中,并调用该函数,它也可以正常工作。一旦我添加了Timer
,python 命令就会继续运行而不显示任何输出,直到我强行停止它。
scapy
以前图书馆也发生过同样的事情。但是在系统重启后它工作正常。但是现在系统重新启动后它也不起作用。
可能是什么问题呢?
注 1: 6 天前,它的行为不是这样的。是否有任何恶意软件的机会?
注2:一种特殊的行为。
###test.py### Version 1
from threading import Timer
from time import sleep
def hello():
print "Hello"
t=Timer(5, hello)
t.start()
sleep(10)
这是我的第1版。它不起作用后,我将其修改为上面提到的第2版。还是没有输出。但是当我按ctrl+时c,它正在显示
from time import sleep as _sleep
File .........., line 2, in <module>
KeyboardInterrupt
尽管那里不存在那行代码。我重新检查了保存的文件是否保存。我还检查了是否有任何pyc
文件造成麻烦。但是没有pyc
。