2012-01-09 30 views
0

下面的第一场是我的Python脚本的一部分:内部的Python ID在数据库

gp.CalculateField_management("parcs", "Apn", "[oldApnfield]") 

的问题是,我从将被命名为不同的每个shape文件的东西计算领域,所以我在计算中不能使用字段名称。有没有一个内部的ID,python用来识别字段?什么是Python语言来说“数据库中的第一个字段”而不是使用字段名称?

感谢您的帮助。我很接近,但现在的计算结果与在新的领域是不是PIDNUM价值PIDNUM每一行.....

import 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:\ZP44" 
fcs = gp.ListWorkspaces("*","Folder") 

# 
for fc in fcs: 
    print fc 
    gp.MakeFeatureLayer(fc + "\\Parcels.shp", "parcs") 
    fieldList = gp.ListFields("parcs") 
    print fieldList[2].Name 
    field1 = fieldList[2].Name 
    print field1 
    gp.CalculateField_management("parcs", "Apn", "[field1]") 
+0

只要使用'fieldList [2] .Name' – aganders3 2012-01-09 22:38:21

回答