title: How do I convert a list of times into Unix epoch time in Python?
body: <p>I'm currently using this to obtain latency: </p>
  
  <pre><code>def time_deltas(infile): 
  entries = (line.split() for line in open(INFILE, "r")) 
  ts = {}  
  for e in entries: 
      if " ".join(e[2:5]) == "TMsg out: [O]": 
          ts [e[8]] = e[0]  
      elif " ".join(e[2:5]) == "TMsg in: [A]":    
          in_ts, ref_id = e[0], e[7] 
          out_ts = ts.pop(ref_id, None) 
          yield (float(out_ts),ref_id[1:-1],(float(in_ts)*1000 - float(out_ts)*1000))
  
  
  INFILE = 'C:/Users/klee/Documents/test.txt'
  print list (time_deltas(INFILE))
  </code></pre>
  
  <p>I would like to convert the float(out_ts) to Unix epoch seconds. </p>
  
  <p>I've tried the following, but have failed miserably: </p>
  
  <pre><code>int(time.mktime(time.strptime('(out_ts)', '%H%M%S.%f'))) - time.timezone
  </code></pre>
  
  <p>AND</p>
  
  <pre><code> t = time.strptime(float(out_ts), "%H%M%S.%f")
          print "Epoch Seconds:", time.mktime(t.timetuple())
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>d = datetime.strptime("out_ts", "%H%M%S.%f")
          time.mktime(d.timetuple())
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>pattern = "%H%M%S.%f"
  epoch = int(time.mktime(time.strptime(out_ts, pattern))
  print 'epoch'
  </code></pre>
  
  <p>Here's an example of a time I want to convert: </p>
  
  <pre><code>82128.668173
  </code></pre>
  
  <p>I'm quite new to Python and any help would be appreciated!!</p>