我需要附加''b'':'''''它要有: mydict = {''a'': ''1',''b'':''2''} 怎么办? 祝你好运, Yves 解决方案 Yves Glodt写道:你好, 例如: mydict = {''a'':''1''} 我需要追加''b'':''2''它有: mydict = {''a'':''1'','b'':''2''} mydict [''b' '] =''2'' Yves Glodt:我似乎无法找到一种方法来将更多的键/值附加到字典的末尾 字典没有订单,因此没有结束。 mydict = {'''':''1''} 我需要附加''b'':'''''它要有: mydict = {''a'':''1'',''b '':''2''} 怎么办? 喜欢这个: mydict = {'''':''1''} mydict [''b''] ='''2' '打印mydict {''a'':''1'','b'':''2''} {'''''''''''' 'b'':''2''} == {''b'':''2'',''''''''1''} 真实 - $ b $bRenéPijlman Yves Glodt写道:我似乎无法找到一种方法将更多的键/值附加到字典的末尾 ... 我怎样才能做到这一点? 字典没有结束,因为它是一个无序的 集合。 例如: mydict = {''a'':''1''} 我需要追加''b'':'''''它有: mydict [''b''] =''2'' 打印mydict http://python.org/doc/2.4.2/tut/node...00000000000000 HTH。 .... jay Hi there,I seem to be unable to find a way to appends more keys/values to the endof a dictionary... how can I do that?E.g:mydict = {''a'':''1''}I need to append ''b'':''2'' to it to have:mydict = {''a'':''1'',''b'':''2''}How to do?Best regards,Yves 解决方案 Yves Glodt wrote: Hi there, I seem to be unable to find a way to appends more keys/values to the end of a dictionary... how can I do that? E.g: mydict = {''a'':''1''} I need to append ''b'':''2'' to it to have: mydict = {''a'':''1'',''b'':''2''}mydict[''b''] = ''2''Yves Glodt:I seem to be unable to find a way to appends more keys/values to the endof a dictionaryA dictionary has no order, and therefore no end.mydict = {''a'':''1''}I need to append ''b'':''2'' to it to have:mydict = {''a'':''1'',''b'':''2''}How to do?Like this: mydict = {''a'':''1''} mydict[''b''] = ''2'' print mydict{''a'': ''1'', ''b'': ''2''} {''a'': ''1'', ''b'': ''2''} == {''b'': ''2'', ''a'': ''1''}True--René PijlmanYves Glodt wrote: I seem to be unable to find a way to appends more keys/values to the end of a dictionary... how can I do that?A dictionary doesn''t have an ''end'' because it is an unorderedcollection. E.g: mydict = {''a'':''1''} I need to append ''b'':''2'' to it to have:mydict[''b''] = ''2''print mydict http://python.org/doc/2.4.2/tut/node...00000000000000HTH.....jay 这篇关于附加到字典的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 13:11