I'm trying to find the maximum value of "CrudeRate" and its associated "State_name" using the following code:
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)
but when I run it I get:
SyntaxError: Can't assign to function call
What is the problem with the code? How can I fix it?
分配 dict 值时,您需要使用括号而不是括号。
out_dict[C] = max(lst)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.