1
我想使用下面的代碼來設置系統日期(而不是時間)。我想將當前時間設置爲新的日期。以下是示例代碼,我發現更改後時間不正確。在Python中,使用win32api沒有設置正確的日期
day = 20
month = 3
year = 2010
timetuple = time.localtime()
print timetuple
print timetuple[3], timetuple[4], timetuple[5]
win32api.SetSystemTime(year, month, timetuple[6]+1,
day, timetuple[3], timetuple[4], timetuple[5], 1)
這需要使用提升的權限運行,因爲普通用戶無權訪問以更改系統時間。 –
@BurhanKhalid:顯然這不是問題;爲OP設定了錯誤的時間。 –
是的,但值得澄清。 –