【发布时间】:2014-06-19 09:36:57
【问题描述】:
我正在尝试制作一个小脚本来使用文本文件中的时间,然后在该数字上加上 30 分钟,然后与“当前时间”进行比较,看看是否已经过了 30 分钟以上...
import os
from time import time, sleep, strftime
with open('timecheck.txt') as timecheck:
last_timecheck = timecheck.read().strip()
print last_timecheck
currenttime = strftime('%H:%M:%S')
if last_timecheck + 30 >= currenttime:
if os.path.exists("../test.csv"):
with open("timecheck.txt", 'wb') as timecheck:
timecheck.write("1")
else:
currenttime = strftime('%H:%M:%S')
with open("timecheck.txt", 'wb') as timecheck:
timecheck.write(currenttime)
任何帮助将不胜感激,我不知道如何正确地做到这一点。
【问题讨论】:
标签: python python-2.7 datetime time strftime