FAQ: 在ArcGIS 9.3中Python的List方法的改变

文章编号 : 34873
软件: ArcGIS - ArcEditor 9.3, 9.3.1 ArcGIS - ArcInfo 9.3, 9.3.1 ArcGIS - ArcView 9.3, 9.3.1
操作系统: N/A
已邀请:

易智瑞技术支持

赞同来自:

问题: 在ArcGIS 9.3中Python的List方法的改变。
回答: 在ArcGIS 9.3中,Geoprocessing编程模型改变了List方法的输出结果。在ArcGIS 9.2中,List方法输出结果是枚举对象,需要使用该对象的Next与Reset方法来进行迭代。

ArcGIS 9.3将List方法的输出结果变成Python列表,它不需要使用Next和Reset方法。下面是例子展示了他们之间的区别。


使用9.3版本的arcgisscripting模块时,List方法返回的结果若使用Next()与Reset()会报错,而在9.2版本中则不会。

受到影响的方法如下:

ListFields()
ListIndexes()
ListDatasets()
ListFeatureClasses()
ListRasters()
ListTables()
ListWorkspaces()
ListEnvironments()
ListToolboxes()
ListTools()
ListInstallations()


ArcGIS 9.2中的ListFeatureClasses方法 import arcgisscripting

gp = arcgisscripting.create()

gp.workspace = r"D:\Data"

fcS = gp.ListFeatureClasses()

fc = fcS.Next()

while fc:

print fc

fc = fcS.Next()


ArcGIS 9.3中的ListFeatureClasses方法 import arcgisscripting

gp = arcgisscripting.create(9.3)



gp.workspace = r"D:\Data"



fcS = gp.ListFeatureClasses()



for fc in fcS:

print fc





创建时间:2008-05-22
最近更新: 2011-05-03


原文链接
http://support.esrichina.com.c ... .html

要回复问题请先登录注册