python词典中的键来自列表
如何打印字典的某些值,在其中我应该从列表中迭代它是键?
fe->我有一个带有密码子的列表:['auu','ggg'],让我们假设auu和ggg在字典中定义为键,它们的值是x和y,我希望能够在整个过程中读取列表并打印x和y。
感谢您的帮助。
How can I print the certain values of a dictionary,where I should iterate it’s keys from a list?
F.e. -> I have a list with codons: [‘AUU’,’GGG’], and let’s assume that auu and ggg is defined in a dictionary as keys, and their values are x and y, I want to be able to read the list throughoutly, and print x and y.
Thanks for the help..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试以下操作:
Try this :
使用项目()方法 - &gt; https://www.geeksforgeeks.orgss.orgs.org/python-dictionary-dictionary-itemms-method/ << /a>
Using items() method -> https://www.geeksforgeeks.org/python-dictionary-items-method/
该代码可以完成工作,
或
代码都返回相同的输出。
输出 -
如果要将值存储在列表中,则只需使用
test.value()
将返回一个类型dict_values
的对象,这是不可能的。因此,将其传递到list()
中,将其转换为列表,使其具有疑问。This code does the job,
OR
Both the code return the same output.
Output -
If you want to store the values in a list just use,
test.value()
returns you an object of typedict_values
which isn't iterable. So passing it insidelist()
converts it into list, making it iterable.