订购字典? [英] Ordered dictionary?

查看:75
本文介绍了订购字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将字符串(键)与整数(值)相关联。字典

可以完成这项工作,除非必须订购。我还要

需要轻松查找特定键的值,所以元组列表

不起作用。

I need to associate a string (key) with an integer (value). A dictionary
would do the job, except for the fact that it must be ordered. I also
need to look up the value for a specific key easily, so a list of tuples
wouldn''t work.

推荐答案

Leif K-Brooks写道:
Leif K-Brooks wrote:
我需要将字符串(键)与整数(值)相关联。字典
将完成这项工作,除非必须订购。我还需要轻松查找特定键的值,因此元组列表
将无法正常工作。
I need to associate a string (key) with an integer (value). A dictionary
would do the job, except for the fact that it must be ordered. I also
need to look up the value for a specific key easily, so a list of tuples
wouldn''t work.




A可以使用字典。当你需要按顺序管理物品时,

你会做什么叫做dict.keys(),然后进行排序。


我不喜欢不知道这有什么用吗......


-

小故障

http://andres980.tripod.com/


"这就是丛林法则。猎人和猎人。报废或

被废弃!

动物追捕生存!

你觉得战争怎么样? ?!"

- Dinobot和Tigatron,丛林法则



A dictionary could be used. When you need to managed the items in order,
what you would do is called dict.keys(), followed by a sort.

I don''t know if this helps at all...

--
Glitch

http://andres980.tripod.com/

"That is the law of the jungle. The hunters and the hunted. Scrap or
be scrapped!"
"Animals hunt to SURVIVE!"
"And what do you think war is about?!"
-- Dinobot and Tigatron, "The Law of the Jungle"


Leif K-Brooks写道:
Leif K-Brooks wrote:
我需要将字符串(键)与整数(值)相关联。字典
将完成这项工作,除非必须订购。我还需要轻松查找特定键的值,因此元组列表
将无法正常工作。
I need to associate a string (key) with an integer (value). A dictionary
would do the job, except for the fact that it must be ordered. I also
need to look up the value for a specific key easily, so a list of tuples
wouldn''t work.




如何必须订购字典吗?你需要钥匙或价值

排序吗?


- Josiah



How must the dictionary be ordered? Do you need the keys or the values
sorted?

- Josiah


>> ;>>> "雷夫" == Leif K-Brooks< eu ***** @ ecritters.biz>写道:


Leif>我需要将字符串(键)与整数相关联

Leif> (值)。字典可以完成这项工作,除了事实

Leif>它必须订购。我还需要查找价值

Leif>对于一个特定的键很容易,所以一个元组列表不会是b $ b $ leif>工作。


google:python有线词典

点击:我很幸运


JDH

>>>>> "Leif" == Leif K-Brooks <eu*****@ecritters.biz> writes:

Leif> I need to associate a string (key) with an integer
Leif> (value). A dictionary would do the job, except for the fact
Leif> that it must be ordered. I also need to look up the value
Leif> for a specific key easily, so a list of tuples wouldn''t
Leif> work.

google : python ordered dictionary
click : I''m feeling lucky

JDH


这篇关于订购字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆