title: Python Floating Point Formatting
body: <p>I've seen a few questions about this already, but none that I read helped me actually understand why what I am trying to do is failing.</p>
  
  <p>So I have a bunch of floating point values, and they have different precisions. Some are 0.1 others are 1.759374, etc. And I want to format them so they are ALL in the form of "+0.0000000E+00" I tried doing</p>
  
  <pre><code>number = '%1.7f' % oldnumber
  </code></pre>
  
  <p>but that didn't work. I thought what I was telling it to do was "one digit perfor the decimal point, and 7 after, float" but it doesn't work. I'm not really getting the examples in the docs, which don't seem to even bother with "before and after decimal point" issues, and I didn't find a question that was about before and after decimal point fixing.</p>
  
  <p>Now, I know that some of my numbers are 0.0437 or similar, and I want them to appear as 4.3700000E-02 or something. I was sort of hoping it would do the E bit on it's own, but if it doesn't how do I do it?</p>
  
  <p>Here is the exact line I have:</p>
  
  <pre><code>RealValConv =   '%1.7g' % struct.unpack('!f',    RealVal.decode('hex'))[0]
  </code></pre>
  
  <p>RealVal is a hex number that represents the value I want.</p>
  
  <p>Also, this is in Python 2.7</p>