def main():
oldimage = loadLastImage()
while True:
image=screenGrab()
if not equal(image,oldimage):
dosomething()
saveLastImage(image) # this is the opposite of loadLastImage()
oldimage=image
# this is the more accepted way of running main
# because it still allows your code to be loaded as module
if __name__ == "__main__":
main()
使用全局变量几乎从来都不是正确的解决方案。它通常会导致比解决方案更多的问题。从@MartijnPieters继续,我将按照以下方式组织您的代码:
相关问题 更多 >
编程相关推荐