I need help with some code. I need to add a back slash in front and end of values in a fields.
I can do it in arcpy.CalculateField_management like this arcpy.CalculateField_management(Merge_Layer, "Location", "''.join(('\'CITY!,'\'))", "PYTHON_9.3", "")
But i am not sure who to do it with arcpy.da.UpdateCursor, any help would be great.
I have this but it's not working.
with arcpy.da.UpdateCursor(fc, "CITY") as cursor: for row in cursor: row[0] = row[0].format(str(!CITY!),"/") cursor.updateRow(row)
Solved! Go to Solution.
with arcpy.da.UpdateCursor(fc, "CITY") as cursor: for row in cursor: row[0] = "".join(("\\", row[0], "\\")) cursor.updateRow(row)
with arcpy.da.UpdateCursor(fc, "CITY") as cursor: for row in cursor: row[0] = "".join(("\\", row[0], "\\")) cursor.updateRow(row)
my second attempted was
row[0] = ''.join(('\'row[0],'\'))
but now I see thanks,