how to find a lable quickly?

wang frank fw3 at hotmail.co.jp
Fri May 4 15:32:06 EDT 2007


Hi,

I am a new user on Python and I really love it. 

I have a big text file with each line like:

label             3
teststart       5
endtest      100
newrun     2345

I opened the file by uu=open('test.txt','r') and then read the data as 
xx=uu.readlines()

In xx, it contains the list of each line. I want to find a spcefic labels 
and read the data. Currently, I
do this by
for ss in xx:
   zz=ss.split( )
  if zz[0] = endtest:
    index=zz[1]

Since the file is big and I need find more lables, this code runs slowly. 
Are there anyway to speed up the process? I thought to convert the data xx 
from list to a dictionay, so I can get the index quickly based on the 
label. Can I do that effeciently?

Thanks

Frank

_________________________________________________________________
メッセンジャーお友達紹介プレゼント第2弾開始!ラスベガス旅行プレゼント 
http://campaign.live.jp/dizon/ 




More information about the Python-list mailing list