使用http时间设置系统时间,http时间设置系统,ubuntu 12.04
使用http时间设置系统时间,http时间设置系统,ubuntu 12.04
ubuntu 12.04,python2.7 可用
#-*-coding:utf8 -*-import httplib as clientimport timeimport osdef get_webservertime(host): conn=client.HTTPConnection(host) conn.request("GET", "/") r=conn.getresponse() ts= r.getheader('date') #获取http头date部分 #将GMT时间转换成北京时间 local_time= time.mktime(time.strptime(ts[5:], "%d %b %Y %H:%M:%S GMT")) + (8 * 60 * 60) ltime = time.gmtime(local_time) #使用date设置时间 dat = 'date -u -s "%d-%d-%d %d:%d:%d" ' % (ltime.tm_year,ltime.tm_mon,ltime.tm_mday,ltime.tm_hour,ltime.tm_min,ltime.tm_sec) os.system(dat)get_webservertime('www.baidu.com')#该片段来自于http://byrx.net
相关内容
- python访问hbase数据,python访问hbase,#!/usr/bin/p
- Python Windows 桌面备份,python备份,print '=====
- 清理用浏览器保存的网页资源,浏览器资源,一般我们用
- 获取今天日期的指定格式,获取日期指定格式,可以制定
- Python通过ctypes调用windows api函数ShellExecute,ctypesshellex
- 输出乘法表到excel,输出乘法表excel,暂不支持xlsx格式
- 淘宝面试题猜数字游戏,淘宝试题猜数字,CNT 看到一个
- 太极,,matplotlib画散
- Python脚本写的命令行下的词典,python脚本,这个一个非常
- python 获得当前线程对象实例,python当前,python中的Thre
评论关闭