Python基础-dict字典
来源:互联网 发布:知微科技 上市了吗 编辑:程序博客网 时间:2024/05/02 13:32
#!usr/bin/env/ python
#coding:utf-8
#dict字典
items = [('name','lichanglin'),('age',24)]
print(items)
print(dict(items))
dict1 = dict(name = 'wangwang',age = 42)
print(dict1)
#字典的格式化字符串
phone = {}
phone['benth'] = '3342'
phone['alex'] = '4456'
phone['wlad'] = '4567'
print(phone)
x = {'wlad':'3467'}
print('benth\'s phone number is %(benth)s.'%phone)
#字典方法:clear/copy/get/has_key/items/keys/pop/popitem/update/values
print(phone.get('benth'))
print(phone.get('sdfg'))
print(phone.keys())
print(phone.values())
print(phone.items())
phone2 = phone.copy()
print(phone2)
print(phone.pop('wlad'))
print(phone)
print(phone.popitem())
print(phone)
#phone2 = phone.copy()
print(phone.update(x))
print(phone)
#coding:utf-8
#dict字典
items = [('name','lichanglin'),('age',24)]
print(items)
print(dict(items))
dict1 = dict(name = 'wangwang',age = 42)
print(dict1)
#字典的格式化字符串
phone = {}
phone['benth'] = '3342'
phone['alex'] = '4456'
phone['wlad'] = '4567'
print(phone)
x = {'wlad':'3467'}
print('benth\'s phone number is %(benth)s.'%phone)
#字典方法:clear/copy/get/has_key/items/keys/pop/popitem/update/values
print(phone.get('benth'))
print(phone.get('sdfg'))
print(phone.keys())
print(phone.values())
print(phone.items())
phone2 = phone.copy()
print(phone2)
print(phone.pop('wlad'))
print(phone)
print(phone.popitem())
print(phone)
#phone2 = phone.copy()
print(phone.update(x))
print(phone)
0 0
- Python基础-dict字典
- python基础篇--Dict(字典)
- Python基础之字典dict
- Python基础入门(十二)- dict 字典
- Python 字典(dict) 操作基础
- Python中dict 字典
- python dict字典
- python dict字典
- python dict字典
- Python dict 字典
- python 字典 dict
- python字典dict
- Python中的字典dict
- python--Dict字典概述
- 6 Python字典dict
- python:字典(dict)
- python dict 字典 总结
- Python-dict字典
- activity中的R文件报错:cannot resolve symbol ‘R’
- MTK 开发流程和开发环境
- jaxen作用
- git lfs 用于二进制文件等非代码文件的版本控制
- 多态
- Python基础-dict字典
- XLT的unity3D学习笔记(三)
- Django下静态模板的继承
- 4774. 【GDOI2017模拟9.10】子串
- UVa - 10082 - WERTYU (常量数组的使用)
- RSA加密算法
- 腾讯优测优分享 | Android适配中的一些特殊情况小结
- 【BZOJ3226】【codevs2297】校门外的区间,线段树
- 产品定位,什么是产品?什么是产品定位?