1
任何人都可以幫助我修改這些腳本來忽略錯誤並繼續運行嗎?我只需要弄清楚如何讓腳本跳過這些錯誤並完成其餘的行。EOL停止計算字段上的python
以下是完整的Python腳本:
# Import system modules
import sys, string, os, arcgisscripting
# Create the geoprocessor object
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = True
# Set the workspace. List all of the folders within
gp.Workspace = "C:\ZP4"
fcs = gp.ListWorkspaces("*","Folder")
for fc in fcs:
print fc
gp.CalculateField_management(fc + "\\Parcels.shp", "SIT_FULL_S", "myfunction(!SIT_HSE_NU!,!SIT_FULL_S!)", "PYTHON", "def myfunction(fld1,fld2):\n if (fld1=='0'or fld1=='00'or fld1<'00000000000'):\n return ''\n else:\n return fld2")
,這裏是錯誤我遇到: 回溯(最近通話最後一個):
File "C:\Documents and Settings\Andrew\Desktop\HOUSENUMERZERO.py", line 18, in
<module>
ERROR 000539: Error running expression: myfunction
(" ","69 FLOOD ST
") <type 'exceptions.SyntaxError'>: EOL while scanning single-quoted string (<st
ring>, line 1)
Failed to execute (CalculateField).
@ dr.parcel:種類。它還不完全正確嗎? – 2011-05-10 17:53:15
無論運行哪個腳本,這些命令都需要正確引用或轉義字符串,或者剝離換行符。如果不知道腳本中的內容,就不會有任何人能做到。 – 2011-05-10 18:14:21
@ dr.parcel:「我一直試圖逃避角色數月」?那麼也許你應該先問*那個問題。另外,當您閱讀代碼時,請查看代碼格式說明並繼續嘗試使此問題可讀。 – 2011-05-10 20:08:54