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

python¶ÁȡĿ¼ÏÂÎļþ²¢Éú³ÉÈÕÖ¾

ºÜ³¤µÄÒ»¶Î´úÂ룬µ«ºÜÇå³þ¡£¹þ¹þ¡£
import os
from time import strftime
stamp=strftime("%Y-%m-%d %H:%M:%S")
logfile = 'F:\\test\\m-php-framework\\tmp\logs\\error_report.log'
path = 'F:\\test\\'
files = os.listdir(path)
bytes = 0
numfiles = 0
for f in files:
if f.startswith('t'):
info = os.stat(path + f)
numfiles +=1
bytes+=info[6]
if numfiles > 1:
title = 'tiles'
else:
title = 'file'
string = stamp + " -- " + str(numfiles) + " session" +title+","+ str(bytes)+" bytes\n"
file = open(logfile,"a")
file.writelines(string)
file.close()


Ïà¹ØÎĵµ£º

ʹÓÃ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
'''
&nbs ......

ÓÃPythonÌáÈ¡Îļþ¼ÐϵÄÌØ¶¨À©Õ¹ÃûµÄÎļþ

                ÓÃPythonÌáÈ¡Îļþ¼ÐϵÄÌØ¶¨À©Õ¹ÃûµÄÎļþ
      ²»ÖªµÀʲôʱºò£¬ÍøÏÐ×ÅûÓ㬹ÒÁ˸ölinuxµÄÊÓÆÁ½Ì³Ì£¬ÀïÃæÓкܶà¸öÎļþ¼Ð£¬ÓкܶàÎ޹صÄÎļþ¡£Õâ¶ÔÓÚÏñÎÒûÊÕ²ØÀ¬»øÎļþñ±ºÃµÄÈËÀ´Ëµ£¬¼òÖ±ÊÇ ......

¹ØÓÚPythonµÄÁбíappend£¨£©·µ»ØNone¶ÔÏó


ÔÚ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))
Ìáʾ¿Õ¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ