ʹÓÃPython¶ÁSEGYµÀÍ·
×Ô¼ºÓöµ½µÄÒ»¸öÎÊÌâ, WestGecoµÄ3DµØÕðÊý¾Ý, ÌáÈ¡µ¼º½Êý¾Ý:
#!/bin/env python
import sys
import struct
try:
f=open(sys.argv[1],'rb')
except (IOError,Exception):
print '''usage:
scriptname segyfilename
'''
sys.exit(1)
#skip EBCDIC header
try:
f.seek(3200)
except Exception:
print 'Oops! your file is broken..'
#read binary header
binhead = f.read(400)
ns = struct.unpack('>h',binhead[20:22])[0]
if ns < 0:
print 'file read error'
sys.exit(1)
#read trace header
while True:
trchead = f.read(240)
if trchead == '':
break
nav = trchead[224:228]+\
trchead[228:232]+\
trchead[200:204]+\
trchead[204:208]+\
trchead[60:64]
#define output format
nl = struct.unpack('>5i',nav)
print 'QL%-4d%9s%10.2f%10.2f%5s' % (nl[0], nl[1], nl[2]/100.0, nl[3]/100.0, nl[4])
f.seek(ns*4,1)
f.close()
Ïà¹ØÎĵµ£º
from: http://www.cnblogs.com/jimnox/archive/2009/12/08/tips-to-python-challenge.html
Python ChallengeÊÇÒ»¸öÍøÒ³´³¹ØÓÎÏ·£¬Í¨¹ýһЩÌáʾÕÒ³öÏÂÒ»¹ØµÄÍøÒ³µØÖ·¡£ÓëÖÚ²»Í¬µÄÊÇ£¬ËüÊÇרÃÅΪ³ÌÐòÔ±Éè¼ÆµÄ£¬ÒòΪ´ó¶àÊý¹Ø¿¨¶¼Òª±à³ÌÀ´ËãŶ£¡£¡
È¥ÄêºÍͬѧһÆðÍæµÄ£¬Ëû×öÁË´ó°ë£¬ÎÒ×öÁËС°ë£¬×÷±×ÁËһЩ£¬33¹Øȫͨ£¬½ ......
1£¬±àдServer.py
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(('localhost',8081))
while True:
data,addr=s.recvfrom(1024)
print 'receive:',data,'from',addr
2£¬±àдClient.py
import socket
s=socket.socket(socket.AF_INET,socket.SOC ......
Íò¶ñµÄ±àÂë
С²Ë¶ÔÓÚÀÏʦÉÏÒ»½Ú½²µÄ²»ÊǺÜÃ÷°×£¬ÒòΪûÓÐÒ»±¾ÊéÊǽ«ÎļþÓëwebÒ»Æð½²Êڵģ¬Ëû¾ö¶¨×Ô¼ºÌ½¾¿Ò»ÏÂËüÃÇÖ®¼äµÄ²»Í¬£º
Ê×ÏÈ£¬Ð¡²ËÔÚCÅ̽¨ÁËÒ»¸öÎı¾Îĵµ file.txt,ÊäÈëËĸö×Ö£ºÎÒÊÇС²Ë¡£
È»ºó£¬Ð¡²ËÔÚshellÖÐÁ·Ï°ÆðÀ´£º
>>> file=open("c:\\file.txt","r")
>>> data=file.read()
>> ......
ÐèÒªÏÈ°²×°libxml2-devel libxslt-develÕâÁ½¸örpm°ü£¬Èç¹ûʹÓ÷ÇrootÓû§°²×°£¬¿ÉÒÔÏÂÔØlibxml2ºÍlibxsltµÄÔ´´úÂë½øÐа²×°¡£ libxml2-devel¡¢libxslt-devel×°ºÃºó£¬½âѹlxmlµÄ°ü£¬Çл»µ½Õâ¸ö°üµÄ·¾¶¡£
¼ÓÈëCFLAGS½øÐбàÒëºÍ°²×°£¬ÔÚshellÏÂÒÀ´ÎÊäÈëÈçÏÂÃüÁ CFLAGS=-I/usr/include/libxml2:/usr/include/libxslt/ ......
list.append(item)
list.extend(sequence)
http://docs.python.org/tutorial/datastructures.html
http://docs.python.org/library/functions.html Õ⼸Ìì¿´Ò»ÏÂ
python howto
¶÷¡£python documentation ȷʵºÜºÃºÜÇ¿´ó°¡£¡
list.append(x)Add an item to the end of the list; equivalent to a[len(a):]&n ......