I am encountering an error in outputting a formatted string. I am using Python2.6
lat = 23.456
long = 34.129
# I want to output lat and long, both occupying 8 columns in width, right justified and with 2 values beyond the decimal point
site_file = open('test.site','w')
site_file.write('[{:8.2f}{:8.2f}]'.format(lat,long))
I get the following error: ValueError: zero length field name in format
Any ideas on what I am doing wrong?
thanks!
longis a buit-in function for converting to a long integer. Please don't use it as a variable name.