문제

I'm looking for some help to do:

1) Get the modification date/time of a file
2) Compare against the same file after a sleep of 10 minuites and if it's not different to play a beep:

import winsound
winsound.Beep(2000,500)

Any ideas?

도움이 되었습니까?

해결책

You will be able to use below function with some modification to fit your requirements:

def getnewestfile(NetworkPath):
    DestFolder = os.getcwd()
    os.chdir(NetworkPath)
    filelist = os.listdir(os.getcwd())
    filelist = filter(lambda x: not os.path.isdir(x), filelist)
    newest = max(filelist, key=lambda x: os.stat(x).st_mtime)
    os.chdir(DestFolder)
    return newest

This function returns the newest file located at the network path as input.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top