ÍøÂçУʱ ¸½PythonÔ´Âë¼°¼¸¸ö±ê׼ʱ¼ä·þÎñÆ÷
ÍøÂçʱ¼ä·þÎñÆ÷ Ò»°ã¶¼×ñÑ RFC868 ÐÒé±ê×¼.
°´¸Ã±ê×¼ ¸½ÏÂÃæ Python Ô´Âë.
# -*- coding: utf-8 -*-
import socket,sys,time
#ʱ¼ä·þÎñÆ÷
host = "stdtime.gov.hk"
#¶Ë¿Ú
port = 37
#ʱÇø
curtz = 8
#Á¬½Ó·þÎñÆ÷,²¢½ÓÊÕ·µ»Ø
try:
host = socket.gethostbyname(host)
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.settimeout(2)
s.sendto("",(host,port))
buf = s.recvfrom(10)[0]
except socket.timeout,ex:
print 'socket error! timeout'
sys.exit(1)
except socket.gaierror,ex:
print 'socket error! gaierror'
sys.exit(1)
if len(buf) < 4:
print 'read data error'
sys.exit(1)
#¼ÆËã·µ»ØµÄ×Ô 1900-1-1 00:00:00 µÄÃëÊý
secs = ord(buf[0])*pow(256,3)+ord(buf[1])*pow(256,2)+ord(buf[2])*pow(256,1)+ord(buf[3])
ts = time.gmtime(secs - 2208988800+curtz*3600)
#time ÊÇ´Ó1970-1-1 00:00:00 ËãÆðµÄ 1970-1-1 00:00:00 ÊÇÃëÊýÊÇ 2208988800s
print time.strftime("%Y-%m-%d %H:%I:%S", ts)
print time.strftime("%Y-%m-%d %H:%I:%S")
#¸½ Time Server:
'''
clock.psu.edu
ntp0.cornell.edu
salmon.maths.tcd.ie
stdtime.gov.hk
'''
תÔØÇë×¢Ã÷³ö´¦ http://blog.csdn.net/mrshelly »ò http://www.mrshelly.com
Ïà¹ØÎĵµ£º
ÀµÓºƣ¨http://laiyonghao.com£©
½ñÌ죨2009Äê5ÔÂ31ÈÕ£© OurPNP.org ¸ãÁ˸ö¾Û»á»î¶¯£¬ÅªÁËÊ®¼¸¶þÊ®¸öÈËÔÚ¹ãÖݺ£Öé¹ã³¡µÄÌûá´ôÁËÎå¸öСʱ£¬´´ÏÂÁËÎÒÔÚ K ·¿´ôµÄ×ʱ¼ä¼Í¼¡£Ó¦ËûÃǵÄÑûÇ룬ÎÒ×öÁ˸öÌâΪ¡¶Óà python ¿ìËٴÍøÓηþÎñÆ÷¡·µÄСÑݽ²£¬ÒòΪÄDZߵĵçÊÓ¾¹È»²»ÄܽӵçÄÔ£¬ËùÒÔ½²µÄʱºòûÓÐÄܹ»²ÎÕÕ PPT À´½²£¬¹Û ......
1¡¢ÏÂÔØoracleÈí¼þ
http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
oracle-instantclient-basic-10.2.0.4-1.i386.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
oracle-instantclient-devel-10.2.0.4-1.i386.rpm
2¡¢°²×°rpm°ü
rpm -ivh oracle-instantclient-basic-10.2.0.4 ......
1. Python ´®¿ÚÉ豸ӦÓÃ
¼òÊö
1.1. Ïß³ÌÂÖÑ°
·ç³¾ÎÞÏÞ <tianyu263@163.com>
-- ·ÖÏí
¾ÍÊÇ´ò¿ª´®¿Úºó£¬Æô¶¯Ò»¸öÏß³ÌÀ´¼àÌý´®¿ÚÊý¾ÝµÄ½øÈ룬ÓÐÊý¾Ýʱ£¬¾Í×öÊý¾ÝµÄ´¦Àí£¨Ò²¿ÉÒÔ·¢ËÍÒ»¸öʼþ£¬²¢Ð¯´ø½ÓÊÕµ½µÄÊý¾Ý£©¡£
Toggle line numbers
1
2 #coding=gb18030
3
4 i ......
½ñÌì¿´¿´ÈçºÎÓÃpythonʵÏÖ×¥°ü¡£
ÒÔÇ°ÎÒÃÇÔøÓùýwinpcapʵÏÖ×¥°ü£¬Æäʵ½ñÌìÎÒÃÇ»¹ÊÇÓÃËü£¬Ö»²»¹ýÊÇËüÔÚpythonϵÄÄ£¿é£¬ÔÚÓÃ֮ǰÎÒÃDZØÐëÏÈÏÂÔØÁ½¸ö¿â£¬pcap¿âºÍdpkt¿â£¬Õâ¸ö¿ÉÒÔÔÚGoogle codeÀïºÜÈÝÒ×ÕÒµ½£¬ÐèҪעÒâµÄÊÇpcapÖ»Ö§³Öµ½python2.5 £¬ËùÒÔÎÒÃÇÒªÓÃ2.5À´±àд¡£
°²×°ÍêÁ ......
×ÛÊö
¶àÏß³ÌÊdzÌÐòÉè¼ÆÖеÄÒ»¸öÖØÒª·½Ã棬ÓÈÆäÊÇÔÚ·þÎñÆ÷Deamon³ÌÐò·½Ãæ¡£ÎÞÂÛºÎÖÖϵͳ£¬Ï̵߳÷¶ÈµÄ¿ªÏú¶¼±È´«Í³µÄ½ø³ÌÒª¿ìµÃ¶à¡£
Python¿ÉÒÔ·½±ãµØÖ§³Ö¶àÏ̡߳£¿ÉÒÔ¿ìËÙ´´½¨Ï̡߳¢»¥³âËø¡¢ÐźÅÁ¿µÈµÈÔªËØ£¬Ö§³ÖÏ̶߳Áдͬ²½»¥³â¡£ÃÀÖв»×ãµÄÊÇ£¬PythonµÄÔËÐÐÔÚPython
ÐéÄâ»úÉÏ£¬´´½¨µÄ¶àÏß³Ì¿É ......