Q:

python pyfits, reading header information and using in calculation

I am running some code with python and pyfits and I am reading out a line of information from the header. I am getting the correct line but due to how it is written in the header it is printing out with colons separating the numbers I need.
the line I am running is
print header[0].header['opp']
this prints
34:04:32.04
I need to do a calculation where I add these numbers together, but do not know how to do this as they are separated by colons.

A:

Something like this should solve your problem:
header[0].header['opp'] = "34:04:32.04"
print (sum(float(x) for x in header[0].header['opp'].split(":")))

... which outputs:
70.03999999999999

(EDIT)
Or, if the values actually make up a time in hours, minutes and seconds:
s = "34:04:32.04"
ss = [float(x) for x in s.split(":")]
print (ss[0] + ss[1]/60 + ss[2]/3600)

... which outputs the value in hours:
34.07556666666667

