¹ØÓÚpython¶ÁÁÐÊý¾Ý
a.txt
ÎļþÄÚÈÝÈçÏ£¨ÆäÖпհײ¿·Ö¶¼ÊÇÒÔtab¼ü¸ô¿ª£©£º
om 2 0.68 0.83 0 0 0 0 0 0
pos
ppa 17 0.74 0.9 0 0 0 1 2 2
ppc 2 2 0.51 0.75 0 0 1
È»ºóÓÃÒÔÏ´úÂë²Ù×÷Õâ¸öÎı¾Îļþ
f = open("a.txt")
for aline in f.readlines():
//ʵÏÖ´úÂë
ÏÈÆ¥ÅäµÚÒ»ÁÐÃû³Æ£¬È»ºóʵÏÖ¶ÁÈ¡¸ÃÐеÚËÄÁеÄÊý¾Ý¡£Èç¹ûΪ¿ÕµÄÔò·µ»Ø0¡£ÒòΪ¿Õ°×²¿·Ö¶¼ÒÔtab¼ü¸ô¿ª£¬ËùÒÔ¿ÉÒÔÑϸñ¶ÁÈ¡µÚËÄÁС£
ÖصãÊÇ£ºÈçºÎÆ¥Åä+ÈçºÎ¶ÁÈ¡µÚËÄÁÐ
×Ô¼ºÊǸöÐÂÊÖ£¬ÊµÏÖ´úÂëÈçºÎд£¬
¶àл¸÷λ¡£
ÊÔ¹ýÓà os.open.(cmd).readlines()д£¬µ«ÊÇÎÒÃǵķþÎñÆ÷¶ÔshellÃüÁîûÓÐȨÏÞ²Ù×÷ËùÒÔÖ»ÄÜÓà ÕâÖÖ·½·¨¡£
eachlineList = aline.split()
if re.match('ppa',eachlineList[0]):#Æ¥ÅäµÚÒ»ÁÐ
print eachlineList[4]££´òÓ¡µÚËÄÁÐ
20%µÄ½áÌùÂÊ
¶÷£¬ÎÒÊÇÐÂÈË¡£
try:
print aline.split('\t').[3]
except:
print 0
Thank you for luckygxboy & yuanvshu.
The solution from luckygxboy is done.
Ïà¹ØÎÊ´ð£º
ÎÒÿ´ÎÉÏ´«µÄÎļþ¶Áµ½µÄÊý¾Ý¶¼²»ÕýÈ·¡£2M µÄͼƬ¶ÁµÃ10¶àK ¡£¡£ÄÄλ´óÏÀ¿ÉÒÔ°ï°ïÎÒ°¡¡£
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......
ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º
1¡¢·áºñµÄ¸å³ê¡£
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......
ÇëÎʸßÊÖ£¬pythonÀïµÄpopenÀàËÆjavaÀïµÄÄĸöÀà»òÕß·½·¨ÄØ£¿£¿ÁíÍâjython¿ª·¢java¸ÃÈçºÎʹÓÃjythonÄØ£¿£¿
1.¿ÉÄܺÍjavaÀïµÄRuntime.getRuntime().exec£¨"ϵͳÃüÁî"£©; Æô¶¯½ø³Ì
2.eclipseÏÂÔØjython ²å¼ ......
×î½üÃÔÉÏÁËPython£¬ÔÚ˼¿¼ÔõÑùÓÃPythonд¸ö³ÌÐòʵÏÖ¶ÔÖ¸¶¨ÍøÂç¶Ë¿ÚµÄÊý¾Ý°üµÄץȡºÍ½âÎö£¬¿ÒÇë¸ßÊÖÖ¸½Ì£¡£¡
ÄãºÃ£¡
Ê×ÏÈ£¬ÊµÏÖ²¶°üµÄ¹¦ÄÜÐèҪʹÓÃwincap£¨windowsÏ£©£¬»òÕßlibpcap£¨LinuxÏ£©¡£
¶øPythonÌṩÁ ......
Àà:
class Test:
def __init__(self,num1,num2):
print num1,num2
ÓÃʲôº¯ÊýÄܲ鿴 TestÀàÓÐÁ½¸ö²ÎÊý
ÄܲéÂð ËÖªµÀ
ÓÃdir ºÍinfoÖÇÄܲ鿴ÊôÐԺͷ½·¨
лл................ ......