[英]Dictionary syntax error "can't assign to function call"
我正在尝试使用以下代码找到“CrudeRate”的最大值及其关联的“State_name”:
import arcpy
arcpy.env.workspace = "C:\\"
shp = r"C:\\USCancer2000.dbf"
rows = arcpy.SearchCursor(shp)
CrudeRate = "CrudeRate"
State_name = "State_name"
out_dict = {}
for row in rows:
for C in CrudeRate:
lst = []
if row.CrudeRate == C:
lst.append(row.CrudeRate)
out_dict(C) = max(lst)
del row,rows
for CrudeRate in out_dict:
print(CrudeRate, State_name)
但是当我运行它时,我得到:
SyntaxError: Can't assign to function call
代码有什么问题? 我该如何解决?
分配 dict 值时,您需要使用括号而不是括号。
out_dict[C] = max(lst)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.