python修改操作系统时间的代码,python操作系统,#-*- coding:
文章由Byrx.net分享于2019-03-23 08:03:14
python修改操作系统时间的代码,python操作系统,#-*- coding:
#-*- coding:utf-8 -*-import socketimport structimport timeimport win32apiTimeServer = '210.72.145.44' #国家授时中心ipPort = 123def getTime(): TIME_1970 = 2208988800L client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) data = '\x1b' + 47 * '\0' client.sendto(data, (TimeServer, Port)) data, address = client.recvfrom(1024) data_result = struct.unpack('!12I', data)[10] data_result -= TIME_1970 return data_resultdef setSystemTime(): tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst = time.gmtime(getTime()) win32api.SetSystemTime(tm_year, tm_mon, tm_wday, tm_mday, tm_hour, tm_min, tm_sec, 0) print "Set System OK!"if __name__ == '__main__': setSystemTime() print "%d-%d-%d %d:%d:%d" % time.localtime(getTime())[:6]
相关内容
- python 抓去指定网页以及该网页上所有链接,python指定
- Python 支持上传的SimpleHTTPServer,,SimpleHTTPSe
- Python 随机生成中文验证码,python中文验证码,python代码
- Python : appendInt, appendShort, appendStr,,python代码impo
- Python 判断一个字节数组是否 beginsWith 另外一个字节数组
- Python 将 Byte Array 保存到文件,pythonarray,python代码impo
- Py4J 示例代码 (Python 调用 Java API),py4jpython,python代码
- python Huffman树,pythonhuffman树,[Python]代码#!
- python 3.3下结合tkinter做的比大小程序,pythontkinter,step1
- Householder similarity transformation of matrix in Python,,''' d,c
评论关闭