在Python中创建一个新的dict [英] Creating a new dict in Python

查看:201
本文介绍了在Python中创建一个新的dict的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Python中构建一个字典。但是,我看到的所有示例都是从列表中实例化一个字典等。



如何在Python中创建一个新的空字典?

解决方案

调用 dict ,无参数

  new_dict = dict() 

或简单地写

  new_dict = {} 


I want to build a dictionary in Python. However, all the examples that I see are instantiating a dictionary from a list, etc . ..

How do I create a new empty dictionary in Python?

解决方案

Call dict with no parameters

new_dict = dict()

or simply write

new_dict = {}

这篇关于在Python中创建一个新的dict的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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