1
을 사용하여 실행되는 프로그램을 만들었습니다. 그리고 그 프로그램은 아무 문제가 없을 때마다 두 번 작동합니다. 기회를 절반으로 줄여서 문제를 해결할 수 있지만, 바로 가기가 적절하지 않습니다.
from systray import SysTrayIcon
from random import randint
def shutprogram(SysTrayIcon):
something = getsomething()
while True:
if getsomething() != something :
something = getsomething()
if randint(0,100) <= 10:
print "STOP, HAMMER TIME!"
stopthis()
else:
print "You may pass"
menu = (('Start', icon.next(), shutprogram),)
SysTrayIcon(icon.next(),"Shut Program",menu)
'getsomething()'이라고 할 때마다'getsomething' 함수가 호출됩니다. 어쩌면 이것을 피하기 위해 임시 변수를 사용하고 싶을 수도 있습니다. – Blorgbeard
그러나 getsomething()은 if-statment를 방해해서는 안되는 다른 함수입니다. –
if 문 ('if getsomething()! = something :')에서 * 호출 *합니다. 그리고 그 결과가 사실이라면, 여러분은 그것을 다시 호출합니다 :'something = getsomething()'. – Blorgbeard