def fmtdeg(fdegree):
    '''convert decimal degree to d m s format string'''
    if abs(fdegree) > 360:
        fdegree = math.fmod(fdegree, 360.0)
    degree = math.fabs(fdegree)
    tmp, deg = math.modf(degree)
    minutes = tmp * 60
    secs = math.modf(minutes)[0] * 60
    sign =''
    if fdegree < 0:
        sign = '-'
    res = '''%s%d%s%d'%.6f"''' % (sign, int(deg), '\N{DEGREE SIGN}',
                            math.floor(minutes), secs)
    return res
convert decimal degree to d m s format string
aa.py