fileinput.input problem

Dave Pawson DaveP at dpawson.freeserve.co.uk
Sun Dec 2 14:32:33 EST 2001


Newbie question on text filtering.

I'm filtering a file, containing a line such as

<ncc:meta name ="timeInthissmil" content="125.63s" />

I want the result to format the number as hh:mm:ss
i.e. I need to pull the content (between quotes) and
do the conversion.

The conversion is not the problem, its finding 
'everything' between quotes.

I have 

def tits(str):
  """Swap time in this smil ='nnns' for hh:mm:ss format """
  timeStringStart=string.find(line,'timeinthissmil')
# line below is suspect.
  timeString=str[timeStringStart+16:timeStringStart+22]

  tim = eval(timeString)
  print "As int", int(tim)
  hrs= int(divmod(tim, 60)[0])
 
  minsR = tim - (hrs * 60)
  mins  = int(tim - (hrs * 60))

  secs = int(60 *(minsR - mins))
  tmp = string.zfill(`hrs`,2)+':'+string.zfill(`mins`,2)+':'+string.zfill
(`secs`,2)
  return tmp

How can I only select the part between quotes, so that it works
with values ranging from
0.03
through to

1200.2

Any help appreciated.
TIA DaveP



More information about the Python-list mailing list