我一直在Python IDLE中得到一个意外的缩进错误,但奇怪的是,对我来说,它是在声明之后。我在Notepad ++中检查了它,并尝试删除空格然后手动添加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
之后答案 0 :(得分:0)
应该是
else:
field_value = 1.0 * (c1+c2+c3)/(p1+p2+p3)
print "done"