首页 > 解决方案 > 将变量的值存储在 menory 或 ram 中

问题描述

如何在 ram 中存储特定时间的分钟并在应用程序再次运行时重用它。就像在电脑关闭时也要存储它,它必须将其保存在货币或内存中或保存价值存储的某个地方

import time
import sys
store_time = time.strftime("%M") // this is the current minutes
time_val = 2 // this is the max hour of used 
store_value = store_time /60
if store_value == time_val:
    print('you reach the max of use of the app')
    exit()

标签: python

解决方案


如果您希望在设备关闭时保持这种状态,您需要写入磁盘。按照这里的例子。然后像这样再次读入


推荐阅读