Datacamp-python-Dictionaries
来源:互联网 发布:财达大智慧软件下载 编辑:程序博客网 时间:2024/06/01 07:39
1.
Motivation for dictionaries--list中index()的应用,即返回索引,zero-based
# Definition of countries and capital
countries = ['spain', 'france', 'germany', 'norway']
capitals = ['madrid', 'paris', 'berlin', 'oslo']
# Get index of 'germany': ind_ger
ind_ger=countries.index('germany')
# Use ind_ger to print out capital of Germany
print(capitals[ind_ger])
<script.py> output:
berlin
2.
Access dictionary
# Definition of dictionary
europe = {'spain':'madrid', 'france':'paris', 'germany':'berlin', 'norway':'oslo' }
# Print out the keys in europe
print(europe.keys())
# Print out value that belongs to key 'norway'
print(europe['norway'])
europe = {'spain':'madrid', 'france':'paris', 'germany':'berlin', 'norway':'oslo' }
# Print out the keys in europe
print(europe.keys())
# Print out value that belongs to key 'norway'
print(europe['norway'])
3.
阅读全文
0 0
- Datacamp-python-Dictionaries
- Python[八]:Dictionaries
- Python中Dictionaries浅析
- Beginning Python - Chapter4 : Dictionaries
- learning Python-Dictionaries
- 3.11 - Dictionaries in Python
- Think Python: Chapter 11 Dictionaries
- Python 入门教程 8 ---- Python Lists and Dictionaries
- Python学习——Lists and Dictionaries
- Python 的Lists、Tuples、Dictionaries和Sets
- Python初学 set集合以及Dictionaries字典
- Python dict dictionaries Python 数据结构——字典
- Python dict dictionaries Python 数据结构——字典
- Python sorting list of dictionaries by multiple keys
- Python学习笔记(7)Mouse Input, More Lists and Dictionaries
- 网站推荐|DataCamp
- Datacamp Notes: Introduction to R
- Python学习笔记(4)——Python Lists and Dictionaries
- BZOJ 1007-水平可见直线
- Markdown语言详解
- PAT--1052. Linked List Sorting
- Spring 获取属性值
- WSGI学习记录
- Datacamp-python-Dictionaries
- Android 计算软键盘高度
- J
- 数据结构:单链表操作之如何判断链表是否带环及相关操作
- OSGI学习之路之Require-Bundle与Imported-Package
- 链接备份 CVPR2017 Ubuntu vi caffe-python接口
- 使用 JsonConfig 排除 实体对象 建立在一对多的关联关系上 jsonConfig.setExcludes
- Javaweb开发,实现'购物车'的遍历与操作(页面数据刷新、后台操作反馈)
- python高阶函数