I'm trying to calculate a field using the Python window, but I can't seem to figure out how to format the function properly. What's the correct syntax for using a string variable as the expression?
arcpy.CalculateField_management(mapLyr2, "Jurisdicti", "'{0}'.format(tName)", "PYTHON")
I couldn't find an example that answered this question for me. Thanks in advance.
I found a work around, but it doesn't solve the question of formatting. If I change the variable to have double quotes it accepts it. I have to format the variable with the quotation marks wrapped in triple apostrophes, like this:
cName = '''"{0}"'''.format(tName)
Hi Jeoff,
Try
arcpy.CalculateField_management(mapLyr2, "Jurisdicti", "\"{0}\"".format(tName), "PYTHON")