Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÍøÂçУʱ ¸½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


Ïà¹ØÎĵµ£º

Python Project

* PYTHON Ç÷ÏòÓÚ½«¹¦ÄÜÏà½üµÄ¶ÔÏó·Å½øÒ»¸öMODULE£¨Îļþ£©À²»Óõ£ÐĶÔÏó»áÌ«´ó£¬ÒòΪÈç¹û¶ÔÏóÌ«´óÁË£¬ÄÇËü¿ÉÄÜÊÇ×öµÄÊÂÐÔÌ«¶àÁË
   ÐèÒª±»Öع¹¡¢·Ö½â¡£
* ¿ª·¢¸¨Öú¹¤¾ßÊÇPYTHONµÄÒ»¸öÇ¿Ïî¡£Èç¹¹½¨¹¤¾ß¡¢Í³¼Æ¹¤¾ßµÈµÈ£¬Ö»ÒªÓÐÐèÇó£¬ËüÒ»¶¨°ìµÃµ½£¬ÒòΪÕâЩӦÓö԰²È«ºÍÐÔÄÜÒªÇ󲻸ߣ¬·´
   ¶ø¶Ô¿ª· ......

´®¿ÚͨѶµÄpythonÄ£¿é——pySerial

pySerial
Overview
This module encapsulates the access for the serial port. It provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono). The module named "serial" automatically selects the appropriate backend.
It is re ......

pythonѧϰ±Ê¼Ç——pcap×¥°ü

½ñÌì¿´¿´ÈçºÎÓÃpythonʵÏÖ×¥°ü¡£
    ÒÔǰÎÒÃÇÔøÓùýwinpcapʵÏÖ×¥°ü£¬Æäʵ½ñÌìÎÒÃÇ»¹ÊÇÓÃËü£¬Ö»²»¹ýÊÇËüÔÚpythonϵÄÄ£¿é£¬ÔÚÓÃ֮ǰÎÒÃDZØÐëÏÈÏÂÔØÁ½¸ö¿â£¬pcap¿âºÍdpkt¿â£¬Õâ¸ö¿ÉÒÔÔÚGoogle codeÀïºÜÈÝÒ×ÕÒµ½£¬ÐèҪעÒâµÄÊÇpcapÖ»Ö§³Öµ½python2.5 £¬ËùÒÔÎÒÃÇÒªÓÃ2.5À´±àд¡£
    °²×°ÍêÁ ......

pylibpcap: python module for libpcap

#!/usr/bin/env python2
import pcap
import sys
import string
import time
import socket
import struct
protocols={socket.IPPROTO_TCP:'tcp',
           socket.IPPROTO_UDP:'udp',
           socket ......

arcgis python½Å±¾

Script Name: Spider_Create   
#Script Label: Create Spider Diagrams   
#   
#Description:  Custom python script developed to create spider diagrams from points contained   
#in one or two feature classes.  If using two fea ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ