¹ØÓÚPythonÖÐʱ¼äÓë×Ö·û´®Ö±½ÓµÄת»»
>>> import time
>>> import datetime
>>>
now = time.localtime()
>>> now
(2006, 4, 30, 18, 7, 35,
6, 120, 0)
>>> type(now)
<type 'time.struct_time'>
>>>
str_now = time.strftime("%m/%d/%Y %X", now )
>>>
str_now
'04/30/2006 18:07:35'
>>> new_now =
time.strptime( str_now, "%m/%d/%Y %X" )
>>> new_now
(2006,
4, 30, 18, 7, 35, 6, 120, -1)
ÕâÀstrftime ½« struct_time µÄʱ¼ä°´Ö¸¶¨µÄ¸ñʽת»¯³É ×Ö·û´®
strptime ½« ×Ö·û´®°´Ö¸¶¨µÄ¸ñʽת»¯³É
struct_time µÄʱ¼ä
struct_time µÄʱ¼äûÓÐÏֳɵıȽϵĺ¯Êý£¬¿ÉÒÔ½« struct_time ת»¯³É datetime.datetime
>>> d_now = datetime.datetime( *now[:6] )
>>>
type(d_now)
<type 'datetime.datetime'>
>>> d_now
datetime.datetime(2006,
4, 30, 18, 7, 35)
Ïà¹ØÎĵµ£º
python
ÓïÑÔ¸ÅÀÀ
python
½Å±¾¿ÉÒÔ´¦ÀíÍⲿ´«½øÀ´µÄ²ÎÊý ¼´sys.argv[]
£¬argv[]
µÄʹÓÃÓëlinux
ÏÂÏàͬ
python
±¾ÉíÊǽâÊÍÓïÑÔ£¬¿ÉÒÔ¶ÔÊäÈëµÄʽ×ÓÇóÖµ¡£python
Ö§³ÖµÄ¶ÔÏóÈçÕûÊý¶¼ÊÇÁ¢¼´Êý£¬´ËÍâËûÖ§³Ö¸´Êý£¬¼°¶ÔËÄÔòÔËËã½âÊÍ¡£
ptyhon
Ö§³Ö×Ö·û´®£¬·ÅÔÚµ¥/
Ë«ÒýºÅÄÚ£¬×Ö·û´®ÊÇÊý×飬¿ÉÒÔͨ¹ý[i: ......
×Ô¼ºÓöµ½µÄÒ»¸öÎÊÌâ, WestGecoµÄ3DµØÕðÊý¾Ý, ÌáÈ¡µ¼º½Êý¾Ý:
#!/bin/env python
import sys
import struct
try:
f=open(sys.argv[1],'rb')
except (IOError,Exception):
print '''usage:
scriptname segyfilename
'''
&nbs ......
[Ô´´]Python(pysvn)ÌáÈ¡svn°æ±¾¼ä¸Ä¶¯ÎļþÁбí
by AKara 2010.04.29 @ http://blog.csdn.net/akara @ akaras@163.com
---------------------------------------------------------------------
Ï£ÍûʵÏÖÒ»¸öÌáÈ¡Á½¸ösvn revision¼äÓб䶯(Ôö/ɾ/¸Ä)µÄÎļþµÄÁбí
µÄÃüÁîÐй¤¾ß£»¿ÉÒÔ°ïÎÒÃÇÏîÄ¿×öһЩÁ÷ ......
>>> from socket import socket, SOCK_DGRAM, AF_INET
>>> s = socket(AF_INET, SOCK_DGRAM)
>>> s.connect(('google.com', 0))
>>> s.getsockname()
('192.168.1.113', 43711)
Linux:
import socket
import fcntl
import struct
def get_ip_address(ifname):
s = ......
ÔÚLearning Python 3rd ÀïµÚÈý²¿·ÖÁ·Ï°ÌâÓеÀÌ⣺
1.c ±àдfor Ñ»·£¬¶ÔÓÚ×Ö·û´®S£¬·µ»ØÒ»¸öеÄÁÐ±í£¬ÆäÖаüº¬ÁË×Ö·û´®Ã¿¸ö×Ö·ûµÄASCIIÂë¡£
ÎÒµÄ˼·ÊÇ£º
for i in S:
L = [ord(i) for i in S] #Áбí½âÎöµÄ˼·
ÎҵĴíÎó˼·£º
for i in S:
L = L.append(ord(i))
Ìáʾ¿Õ¶ ......