有没有办法在循环运行时检查不断变化的值TEST.Loop
和更改
值( )?TEST.Delay
def Work():
我可以创建 的实例TEST
,并将其更改为 的其他实例TEST
,但我找不到查看Work
循环内的任何值和变量更改的方法。
#!/usr/bin/env python3
from time import sleep
class TEST:
Test = 0
Loop = 0
Delay =.1
def inc_delay(self):
TEST.Delay += 1
print ( 'inc called' , TEST.Delay )
def dec_delay(self):
TEST.Delay -+ 1
def Work():
while TEST.Loop < 10000:
TEST.Loop += 1
sleep( TEST.Delay )
print ( TEST.Loop , TEST.Delay )
if __name__ == '__main__':
TEST.Work()
第二个脚本类似于:
import class_filename
a = class_filename.TEST
a.Delay = whatever