我想创建持有多维值的Python字典接受,它应该是能够扩大,这是值应存储结构: -Python |如何创建动态的,可扩展的字典
userdata = {'data':[{'username':'Ronny Leech','age':'22','country':'Siberia'},{'username':'Cronulla James','age':'34','country':'USA'}]}
比方说,我想添加其他用户
def user_list():
users = []
for i in xrange(5, 0, -1):
lonlatuser.append(('username','%s %s' % firstn, lastn))
lonlatuser.append(('age',age))
lonlatuser.append(('country',country))
return dict(user)
这只会返回与一个单一值的字典(因为这些按键的名称是相同的值将覆盖)。所以我怎么一组值追加到此字典。
注意:假设年龄,firstn,lastn和country是动态生成的。
谢谢。
lontatuser与列表中的用户数据关键数据?你输入字典的用户是什么? – extraneon 2010-03-18 08:32:05