python
来源:互联网 发布:淘宝货到付款怎么关闭 编辑:程序博客网 时间:2024/05/23 14:58
list
[x for x in range(5,101,5)]
dict
#constructoradict = {"d1": 2000, "d2": 3000};print(adict) # {'d1': 2000, 'd2': 3000}bdict = dict([ ["d1", 2000],["d2", 3000] ]);print(bdict) # {'d1': 2000, 'd2': 3000}cdict = dict(d1=2000, d2=3000);print(cdict) # {'d1': 2000, 'd2': 3000}keys = ["d1", "d2"];values = [4000, 3000];ddict = dict(zip(keys, values));print(ddict); #{'d1': 4000, 'd2': 3000}#changeddict = cdict;print(ddict) # {'d1': 2000, 'd2': 3000}ddict["d1"] = 4000;print(cdict) # {'d1': 4000, 'd2': 3000}print(ddict) # {'d1': 4000, 'd2': 3000}
set
#可变集合setA = set('Hello, World!')print(setA)setB = set('Hello, Python!')print(setB)print(setA - setB) #{'r', 'W', 'd'}print(setA^setB) #{'P', 'r', 'h', 't', 'W', 'y', 'd', 'n'}#不可变集合setC = frozenset("Test")#setC += set('abc') #unsupported operand type(s) for +=: 'frozenset' and 'set'print(setC) #frozenset({'t', 'e', 'T', 's'})
阅读全文
0 0
- Python
- Python
- Python
- python
- Python
- PYTHON
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- Python
- python
- Python
- 设计模式
- 提高网站并发能力的技术归纳
- Java正则表达式的辨析
- cnpm私有仓库踩坑之旅
- 发送验证码按钮页面计时器
- python
- git回退版本(线上和本地仓库)
- 前端技术工程化的一小点实践
- leetcode题解-123. Best Time to Buy and Sell Stock III
- 分针网—每日分享:移动端适配之rem详解
- oracle创建表空间、用户以及给用户分配权限
- C++标准库addressof的应用
- windows server 2008 R2 和windows 7 安装telnet服务
- CentOS 安装NodeJS V8.0.0