gpt4 book ai didi

python - 如何抑制 Python AttributeError?

转载 作者:行者123 更新时间:2023-12-03 08:09:02 25 4
gpt4 key购买 nike

当我运行 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 theycan take a look at this recently reported issue. I apologize you'rerunning 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com