当我运行 ArcGIS Pro Add Geometry Attributes (Data Management)命令:
arcpy.AddGeometryAttributes_management()
我收到以下错误:Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'ToolValidator' object has no attribute 'isLicensed'
该工具执行它需要做的事情并且工作正常。然而,做一点研究表明这是一个 known bug并且应该被忽略:Yes, given that there is no license requirement for the tool (https://pro.arcgis.com/en/pro-app/tool-reference/conversion/table-to-excel.htm#L_) just ignore and move on. I've pinged the gp team to make sure they can take a look at this recently reported issue. I apologize you're running into it, but looks like it isn't major...
有什么方法可以完全抑制
AttributeError
像这样,所以我在更大的工作流程中看不到错误?
最佳答案
只需运行 try-except
在要忽略错误的代码行周围阻塞。
try:
arcpy.AddGeometryAttributes_management()
except AttributeError:
pass
这将忽略错误并继续。鉴于似乎错误可能在模块中,您可以使用
except:
但是,这将忽略返回的每个错误。
关于python - 如何抑制 Python AttributeError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64096121/