我在c#中编写了这段代码来检查文件是否过时:
DateTime? lastTimeModified = file.getLastTimeModified();
if (!lastTimeModified.HasValue)
{
//File does not exist, so it is out of date
return true;
}
if (lastTimeModified.Value < DateTime.Now.AddMinutes(-synchIntervall))
{
return true;
} else
{
return false;
}
我如何在python中写这个?
我在python中试过这个.
statbuf = os.stat(filename)
if(statbuf.st_mtime < datetime.datetime.now() - self.synchIntervall):
return True
else:
return False
我得到以下异常
message str: unsupported operand type(s) for -: 'datetime.datetime' and 'int'