python - python中的多维数组
问题描述
在 php 中,我们可以创建多维关联数组,例如
$item = array(
"spec" => array(
"more" => "smth"
))
并遍历它们foreach($item as $a => $b)
我想知道我是否可以做同样的事情,包括 python 中的迭代过程
解决方案
是的,您可以使用这样的字典(字典)(python 3):
item = {"spec": {"more": "smth"}}
for key, value in item.items():
print("The key was '" + key + "' and the value was:")
print(value)
推荐阅读
- upgrade - TypeError:升级到 NestJs 5.1 时无法读取属性“名称”错误
- python-3.x - Pandas:当列值重叠时使用精确匹配合并一列
- instagram - 如何在 Instagram 中获取用户供稿?
- java - Executors.newFixedThreadPool 如何停止同步方法上的所有活动线程
- php - HHVM 和 APC/其他 opcache 的优势是什么?
- python - Python: KeyError: u'key' 分析多个 netCDF 文件时
- reactjs - 从输入文件处理文件并稍后上传反应redux
- python - Keras - 深度学习模型不训练
- angularjs - 如何通过 github 从子文件夹部署 AngularJs 应用程序?
- python-3.x - python formattng 输出和输入