¹ØÓÚ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µÄ7±¾Êé
°üÀ¨6±¾chm£¬Ò»±¾pdf×ÊÁÏ
¶ÔѧϰpythonÓкܴóµÄ°ïÖú
http://download.csdn.net/source/619791
¾«ÐÄËѼ¯£¬²»Òª»ý·Ö£¬ÄóöÀ´·ÖÏí
лл¥Ö÷£¬ÐÁ¿àÁË~
lz ×îºÃ°ÑÊéÃûºÍ¼òµ¥½éÉܼÓÉ ......
ÈçºÎ½«PythonдµÄÒ»¶Î´úÂëÉú³ÉpydÐÎʽµÄ¿â?
ÎÒÖªµÀµÄ·½·¨ÓУº½«Õâ¶ÎPython´úÂëÀ©Õ¹³ÉC´úÂ룬Ȼºóͨ¹ýVC½«Õâ¶ÎC´úÂëÉú³Éºó׺Ϊ.pydµÄ¶¯Ì¬Á´½Ó¿â¡£
²»ÏëÓÃÕâô±¿µÄ·½·¨£¬ÇëÎÊÓÐûÓбȽϼòµ¥µÄ·½·¨£¿Ð»Ð»£¡
¶¥Ò»Ï£¬ ......
map£¬filter·½·¨Ó¦¸Ã»á·µ»ØÒ»¸öÁÐ±í¡£
µ«ÊÇÔÚÎÒÕâÀËüÃÇ×ÜÊÇ·µ»Ø£º
<map object at 0x0000000002A2C978>
<filter object at 0x0000000002A2C9E8>
ÎÒÓõÄpython3.1£¬ Õâ¸öÒ²ÊÇ°æ±¾µÄ±ä¶¯µ¼ÖµÄÂ𣿠......
Àà:
class Test:
def __init__(self,num1,num2):
print num1,num2
ÓÃʲôº¯ÊýÄܲ鿴 TestÀàÓÐÁ½¸ö²ÎÊý
ÄܲéÂð ËÖªµÀ
ÓÃdir ºÍinfoÖÇÄܲ鿴ÊôÐԺͷ½·¨
лл................ ......