I have a field in a table that contains string values of degrees minutes seconds in the following format:
I want to replace all the dashes and format this to a proper format of:
179° 53' 32"
Basically replacing the dashes with the correct character (degree, minute, second) and having spaces in there. I was thinking about doing a repalce by index, but I don't think it works:
s.replace('-', '° ') s.replace('-', '\' ')
Is there a way to accomplish what I want to do? maybe enumerate the string first and then replace?
This would probably do it:
"%s° %s' %s\"" % s.split('-')
You may need to wrap the call to
s.split in a tuple call. Otherwise I was getting an error. So it becomes this:
"%s° %s' %s\"" % tuple(s.split('-'))