0

我在 Python IDLE 中不断收到意外的缩进错误,但奇怪的是,对我来说,它是在语句之​​后。我在记事本++中检查了它,并尝试删除空格,然后手动添加4,即不是选项卡。下面是代码;该错误在 field_value 语句之后突出显示。我们欢迎所有的建议

一世

import arcpy, sys

arcpy.env.workspace = "C:\\"
shapefile = "USCancer2000.shp"
field_name = "friday"

#Add the field
arcpy.AddField_management(shapefile,field_name,"LONG", "","","","","NULLABLE","NON_REQUIRED","")

cursor = arcpy.UpdateCursor(shapefile)

for row in cursor:
    #Get the value of each of our fields, and put them into variables
    c1 = row.getValue("Cnt1")
    c2 = row.getValue("Cnt2")
    c3 = row.getValue("Cnt3")
    p1 = row.getValue("Pop1")
    p2 = row.getValue("Pop2")
    p3 = row.getValue("Pop3")

    #check for missing values, assuming that non-missing values are all greater than or equal to zero
    try: 
        if((min(c1,c2,c3,p1,p2,p3) < 0) or ((p1+p2+p3) == 0) ):  t
            field_value = 0
        else:
            field_value= 1.0

错误在 field_value= 1.0 之后

4

1 回答 1

0

它应该是

else:
    field_value = 1.0 * (c1+c2+c3)/(p1+p2+p3)
print "done"
于 2013-04-06T01:02:14.847 回答