파이썬 사전은 실제로 저를 오늘 가지고 있습니다. 나는 스택 위에 쏟아져 내려 왔고 파이썬 사전에있는 기존 키에 새로운 값을 추가하는 간단한 방법을 찾으려고 노력했다. 나는 모든 시도에서 실패하고 여기서 본 것과 같은 구문을 사용하고있다. 파이썬 사전에서 하나의 키에 여러 값 추가하기
#cursor seach a xls file
definitionQuery_Dict = {}
for row in arcpy.SearchCursor(xls):
# set some source paths from strings in the xls file
dataSourcePath = str(row.getValue("workspace_path")) + "\\" + str(row.getValue("dataSource"))
dataSource = row.getValue("dataSource")
# add items to dictionary. The keys are the dayasource table and the values will be definition (SQL) queries. First test is to see if a defintion query exists in the row and if it does, we want to add the key,value pair to a dictionary.
if row.getValue("Definition_Query") <> None:
# if key already exists, then append a new value to the value list
if row.getValue("dataSource") in definitionQuery_Dict:
definitionQuery_Dict[row.getValue("dataSource")].append(row.getValue("Definition_Query"))
else:
# otherwise, add a new key, value pair
definitionQuery_Dict[row.getValue("dataSource")] = row.getValue("Definition_Query")
내가 속성 오류 얻을 :
AttributeError: 'unicode' object has no attribute 'append'
을하지만 대답은 here
을 제공 한 내가 같은 일을하고 생각
이
내가 일을하려고하고있는 무슨이다 여러 가지 다른 오류 메시지와 함께 운이없는 다양한 다른 방법을 시도했습니다. 나는 이것이 아마 간단하고 어쩌면 내가 웹상에서 적절한 출처를 찾을 수 없다는 것을 알고 있지만, 나는 붙어있다. 누구든지 도와 주겠니?감사합니다, 마이크
Ughh ... 나는 이런 것을 필요로한다는 것을 알았다. 값을 목록으로 설정하려면. 나는 내가 너무 많은 예제를 보았을 때 자신을 혼란스럽게 생각했다. 이것은 내가 필요한 것입니다. 감사! – Mike