¹ØÓÚ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.
Ïà¹ØÎÊ´ð£º
ÒÑÖªPython ÖУº
s = unicode("²âÊÔ", "gb2312")
s = u'\u6d4b\u8bd5'
print s
²âÊÔ
ÔÚDelphiÀïÃæÈçºÎ½«\u6d4b\u8bd5ÕâÑùµÄ»¹Ô³ÉGb2312µÄºº×ÖÄØ£¿
ÕÒµ½¸ö·½·¨
......
ËÍÆ¼öÒ»±¾Ñ§Ï°PYTHONµÄÊ飬лл
¡¶python¼òÃ÷½Ì³Ì¡·£¬¡¶pythonºËÐıà³Ì¡·
×÷Ϊϵͳ¹ÜÀí·½Ãæ£¬¡¶Python UNIXºÍLinuxϵͳ¹ÜÀíÖ¸ÄÏ¡·ÊDZ¾·Ç³£²»´íµÄÊé¡£
http://club.book.csdn.net/pic3/255142.jpg
ÒýÓÃ
×÷Î ......
ÓźñµÄ¸å³ê£¬³ÏÕÐPython¼¼ÊõÈËÔ±²ÎÓë¸÷ÖÖ¼¼ÊõÊé¼®³ö°æ¡£
ͨ¹ý¸ÃÊé¼®£¬×÷Õß¿ÉÒԵõ½Èçϱ¨³ê£º
1¡¢·áºñµÄ¸å³ê¡£
2¡¢Êé¼®Öø×÷µÄÊðÃûȨ¡£
3¡¢¶Ô×÷ÕߺÍÊé½øÐÐÐû´«£¬Ìá¸ß×÷ÕßÔÚ¼¼ÊõȦ×ÓÀ ......
ÔÚÎı¾ÎļþÖÐÆ¥ÅäÏî°üº¬ÖÐÎÄ
ÈçÄÚÈÝΪ£ºgamename=ÖÐÎÄ
key=ÌìÏÂ
Îı¾ÎļþµÄ±àÂëµÄÎļþΪutf-8
python´úÂëÈçÏ£º
# -*- coding:UTF-8 -*-
contents=open(from_pa ......
ËÓÐpython django ¿ª·¢µÄ³ÌÐò »òÕßÖªµÀÄÄÓÐ
¸æËßÏ ÎÒÒªÒ»¸ö¿ªÔ´µÄ³ÌÐòѧϰÓà ¸Ð¾õ×Ô¼º±à³ÌºÜ²»¹æ·¶
µã»÷²é¿´¡¶Django Web ¿ª·¢Ö¸ÄÏ¡·
http://www.ibm.com/developerworks/cn/linux/l-django/
Äã˵µÄÊÇdj ......