如何使用 Python 字典? [英] How to use a Python dictionary?

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

问题描述

我发现在 python 中遍历字典很困难.

I am finding it difficult to iterate through a dictionary in python.

我已经通过 CodeAcademy 完成了学习并单独学习,但仍然觉得翻阅字典很困难.

I have already finished learning via CodeAcademy and solo learn but still find it tough to go through a dictionary.

除了 Python 的官方文档之外,还有什么好的资源可以让我学习更多并以清晰的语言提供,让我可以更熟悉 Python.

Are there any good resources other than official documentation of Python to learn more and given in lucid language where I can be more comfortable with python.

推荐答案

有许多不同的 Python 在线文档和教程资源,根据您的需要,几乎每一种都有帮助.但最可靠的文档是 Python 网站的官方文档.

Lots of different documentations and tutorial resources available for Python online, almost each of them are helpful depending upon your need. But most reliable documentation is official documentation of Python website.

另请观看相同的 YouTube 视频,许多词典和其他 Python 结构的实际实现视频都以易于理解的方式提供.

Also please watch youtube videos of the same, many videos of practical implementation of dictionaries and other Python constructs are available in easy to understandable manner.

这是字典实现的示例程序:

Here is sample program for dictionary implementation:

my_dict = {'name':'Deadpool', 'designation': 'developer'}
print(my_dict)
Output: { 'designation': developer, 'name': Deadpool}

# update value
my_dict['designation'] = 'sr developer'

#Output: {'designation': sr developer, 'name': Deadpool}
print(my_dict)

# add an item to existing dictionary
my_dict['address'] = 'New York'  
print(my_dict)
# Output: {'address': New York, 'designation': sr developer, 'name': Deadpool}

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

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