arcpy.CalculateField_management("GISMainFabric_Line_Clip_0","Bear",'[NUM1] & "°" & [NUM2]',"VB") File "C:\Users\Administrator\AppData\Local\ESRI\Desktop10.1\AssemblyCache\{7F12A0CE-D617-8330-5EBC-E045415D9345}\PlanTool_addin.py", line 105 SyntaxError: Non-ASCII character '\xb0'
Solved! Go to Solution.
...if I may, I'd like to comment just a bit further on this - I thought I saw a better answer somewhere else a while back so out of curiosity I made a note to look later for it and lo and behold, here is something I think will even appeal to Richard (because it contains a single answer, at the time of this post anyway), please see the below.
This is the work posted by Mike Toews and Tanner:
Field Calculate Degree Minute Second in Different Format
http://gis.stackexchange.com/questions/30754/field-calculate-degree-minute-second-in-different-forma...
I didn't realize this, but there's unicode support in ArcMap for the characters degree, prime (minutes), and double-prime (seconds).
These are designated by \u00B0, \u2032, and \u2033', respectively. The apostrophe or single-quote character substitution for minutes will do fine, but since we're talking about it and there's support for it, let's be more exact.
Also, for what it's worth I agree with Matt about making the code more readable -- certainly it has tripped me in comic style like Jerry Lewis or Dick Van Dyke...but back to the point, why not write it in easy fashion without the necessity to escape quotes?
So, try this technique to set the expression (exp):
exp = u"str(%s) + '\u00B0 ' + str(%s) + '\u2032'" % ('!NUM1!','!NUM2!')
...or this, if you like the 'format' approach better:
exp = u"str({0}) + '\u00B0 ' + str({1}) + '\u2032'".format('!NUM1!','!NUM2!')
Then, of course, you can 'plug n play' this exp in the field calculator:
arcpy.CalculateField_management("GISMainFabric_Line_Clip_0", "Bear", exp, "PYTHON_9.3")
Enjoy,
Wayne