import os
import time
filename = "d:\data.txt"
# time.mktime((year, month, day, hour, minute, second, wday, yday, is_dst))
t = time.mktime((2017, 9, 2, 17, 5, 36, 0, 0, 0))
os.utime(filename, (t, t))
print('file last modified: %s' % time.ctime(os.path.getmtime("d:\data.txt")))
# Note - on Windows (7) the hour I set to 17 is set to 18
# so, hour - 1 give us the correct hour we want to set
t = time.mktime((2017, 9, 2, 17 - 1, 5, 36, 0, 0, 0))
os.utime(filename, (t, t))
print('file last modified: %s' % time.ctime(os.path.getmtime("d:\data.txt")))
'''
run:
file last modified: Sat Sep 2 18:05:36 2017
file last modified: Sat Sep 2 17:05:36 2017
'''