开发者

Python - removing double quotation marks " so that script runs

开发者 https://www.devze.com 2023-02-04 22:16 出处:网络
I am using Python scripts to edit the table of many shape files.The following script runs fine, but if there are any \" marks in the SIT_FULL_S field, the script errors and shuts down.

I am using Python scripts to edit the table of many shape files. The following script runs fine, but if there are any " marks in the SIT_FULL_S field, the script errors and shuts down.

gp.CalculateFi开发者_如何学JAVAeld_management(fc + "\\Parcels.shp","SIT_FULL_S", "!SIT_FULL_S!.lstrip('0')", "PYTHON")
arcgisscripting.ExecuteError: ERROR 000539: Error running expression: "9030 W SR 2 HWY "A"".lstrip('0') <type 'exceptions.SyntaxError'>: invalid syntax (<string>, line 1)
Failed to execute (CalculateField).

I have two options, create a new script that runs through and deletes all occurances of ", and then run the above script or modify the above script to ignore the " and contiue running.

Can anyone help ?


Escape it:

"string \"inner string\""

or don't mix quotations:

'string "inner string"'
0

精彩评论

暂无评论...
验证码 换一张
取 消