我一直在用这个代码在我的windows操作系统中改变时区。它工作得很好,但是当我通过datetime.now()
获得新的日期和时间时,它会给出它仍然没有更改的日期和时间。我必须重新运行脚本才能得到正确的日期时间到了。谢谢在
def adjustPrivilege( priv ):
try:
flags = ntsecuritycon.TOKEN_ADJUST_PRIVILEGES | ntsecuritycon.TOKEN_QUERY
htoken = win32security.OpenProcessToken(win32api.GetCurrentProcess(), flags)
id = win32security.LookupPrivilegeValue(None, priv)
newPrivileges = [(id, ntsecuritycon.SE_PRIVILEGE_ENABLED)]
win32security.AdjustTokenPrivileges(htoken, 0, newPrivileges)
except:
pass
# Enable the privilege
adjustPrivilege(win32security.SE_TIME_ZONE_NAME)
# Set the timezone
win32api.SetTimeZoneInformation((-480,u'China Standard Time',(2000,0,0,0,0,0,0,0),0,u'China Standard Time',(2000,0,0,0,0,0,0,0),-0))
time.sleep(5)
print datetime.datetime.now()
目前没有回答
相关问题 更多 >
编程相关推荐