I am new to coding using ArcPy.
My code is:
roadname = "Ly Thuong Kiet"
arcpy.SelectLayerByAttribute_management("inLayer_lyr","NEW_SELECTION",""" "DIA_CHI" LIKE '{0}' """.format(roadname))
This code can run easily. However, I want to choose all the elements belonging to "DIA_CHI" field that have a name in the roadname. Example: "Hem 32 Ly Thuong Kiet" will be contained in ("Ly Thuong Kiet").
When I wrote this code:
arcpy.SelectLayerByAttribute_management("inLayer_lyr","NEW_SELECTION",""" "DIA_CHI" LIKE "%Ly Thuong Kiet")
It can run. But when I use variable , I couldn't use percentage sign (%) in format.