Python float to C-standard string

import os
#
#    This routine converts a float value to a % 12.5e  string with two places for the exponent.
#      Microsoft has decided to defy the C Standards and write out three values in the
#        exponent [-]m.ddddde+xxx  rather than only two per the C STANDARD [-]m.ddddde+xx
#
def float_to_exponent_string(float_val):
    # converts a float to a 12-character string with three-character exponent (windows)
    #   or a two-character exponent on all other platforms.
    # First, get positives and negatives printed out with 13 characters
    #  (positives get padded with a space on left)
    if (os.name == 'nt'):
        out_str = " %12.5e" % float(float_val)
        # first digit of three-digit exponent should be a zero; remove it
        # else round to exponent of 99
        for i in range(len(out_str)):
            if out_str[i] == 'e':
                first_ex = i+2
                break
        #print "\npreconvert: '",out_str,"'"
        #print "out_str[",first_ex,"]: '",out_str[first_ex],"'"
        #print "out_str[0:",first_ex,"]: '",out_str[0:first_ex],"'"
        #print "out_str[",first_ex+1,":13]: '",out_str[first_ex+1:first_ex+3],"'"
        if (out_str[first_ex] != '0'):
            out_str = out_str[0:first_ex] + '99'
        else:
            out_str = out_str[0:first_ex] + out_str[first_ex+1:first_ex+3]
    else:
        out_str = " %12.5e" % float(float_val)
#
    if out_str[1] == '-' or (out_str[0]==' ' and out_str[1]==' '):
        out_str = out_str[1:]

    #print "length out_str = ",len(out_str)
    #print "postconvert: '",out_str,"'"

    return(out_str)