Muszę napisać program w kursie sieciowym, który jest czymś w rodzaju selektywnego powtórzenia, ale potrzebuje zegara. po wyszukiwaniu w Google I okazało się, że threading.Timer może mi pomóc, napisałem prosty program właśnie dla testu jak threading.Timer praca to było tak:threading.Timer()
import threading
def hello():
print "hello, world"
t = threading.Timer(10.0, hello)
t.start()
print "Hi"
i=10
i=i+20
print i
ten program działa poprawnie. ale gdy próbuję zdefiniować funkcję powitania w taki sposób, aby dać parametr jak:
import threading
def hello(s):
print s
h="hello world"
t = threading.Timer(10.0, hello(h))
t.start()
print "Hi"
i=10
i=i+20
print i
obecnie wprowadzone to:
hello world
Hi
30
Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 522, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 726, in run
self.function(*self.args, **self.kwargs)
TypeError: 'NoneType' object is not callable
nie mogę zrozumieć, co to jest problem! czy ktoś mi pomoże?
dziękuję bardzo :) – sandra