【问题标题】:How to get comparison between count and previous using python如何使用python获取计数和以前的比较
【发布时间】:2023-04-05 18:43:01
【问题描述】:

我想比较当前和以前的两件事,我该如何实现,谁能帮助我
提前谢谢你

import threading
import time
count = 1
def compare(a1,a2):
    print("Current value",a1)
    print("previous value",a2)

def increse():
    global count
    datestring = str(time.strftime("%Y%m%d-%H%M"))
    filepath1 = datestring + '_' + str(count) + '.png'
    count += 1
    return filepath1  

def get_old():
    threading.Timer(0.5 * 60, get_old).start()
    a1 = increse()
    # Here how can I store current time as previous for comparision  
    print(a1)
    compare(a1,a2)
get_old()

这里线程连续运行,每次都获取新的a1,我想同时获取当前的a1和以前的a1,如何将以前的值存储为a2

【问题讨论】:

    标签:
    python
    python-3.x
    count
    logic