标签:索引 nbsp class tools style string === message DDM
import arcpy import string ##多少个工具箱 toolboxes = arcpy.ListToolboxes() for toolbox in toolboxes: #截取工具箱的别名 #arcpy.AddMessage("=====" + toolbox) first=toolbox.index("(") ##第一个‘(‘的索引值 #arcpy.AddMessage("first=" + str(first)) end = toolbox.index(")") ##最后一个‘)‘的索引值 #arcpy.AddMessage("end=" + str(end)) toolboxAlias=toolbox[first+1:end] ##工具箱的别名 #arcpy.AddMessage("toolboxAlias=" + toolboxAlias) i = 0 tools = arcpy.ListTools() for tool in tools: f=tool.index("_") ##"_"的索引值 #arcpy.AddMessage(tool+":"+str(f)) alias=tool[f+1:] #arcpy.AddMessage(tool + ":" + alias) if alias==toolboxAlias: arcpy.AddMessage(tool) i=i+1 arcpy.AddMessage( "====="+toolbox+"‘s count:"+str(i)) arcpy.AddMessage( "the tool count:"+str( len(tools))) arcpy.AddMessage( "the toolbox count:"+str(len(toolboxes)))
标签:索引 nbsp class tools style string === message DDM
原文地址:https://www.cnblogs.com/gisoracle/p/12904539.html