附加到字典的末尾 [英] append to the end of a dictionary
问题描述
你好,
我似乎无法找到一种方法来添加更多的键/值到最后
的字典......我怎么能这样做?
例如:
mydict = {'''':''1''} >
我需要附加''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 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''}
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 end
of a dictionary
A 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é Pijlman
Yves 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 unordered
collection.
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...00000000000000
HTH.
....
jay
这篇关于附加到字典的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!