I am trying to concatenate 2 string variables Var1 and Var2 using python (converting some old ArcGIS VB-based scripts to ArcPy). I need to add a backslash between them.
arcpy.CalculateField_management(TargetDB, "myfield", '!Var1!' + '\\' + '!Var2!', "PYTHON")
I get an error message that says
"SyntaxError: unexpected character after line continuation character"
when the code block runs. I believe the cause of the error is that Var2 contains a forward slash character. It isn't file or folder path related, it's an ID field that acts as a primary key in a database (which is frustrating, but something I can't do anything about).
Given that I can't really modify the values of Var2 because of the database situation, does anyone have any recommendations of a way around this in Python 3 to work in ArcGIS Pro 2.6? The old VB code worked, so I am assuming this is a python specific issue.