Python 容器API
来源:互联网 发布:万达乐园和迪士尼 知乎 编辑:程序博客网 时间:2024/06/13 19:09
list
class list([iterable])
构造方法
- 使用一对方括号表示空列表:[]
- 使用方括号,用逗号分隔项目[a], [a, b, c]
- 使用列表推导式: [x for x in iterable]
- 使用类型构造函数:list()或list(iterable)
对象方法
见Python容器
tuple
构造方法
class tuple([iterable])
- 使用一对括号表示空元组:()
- 对单个元组使用尾随逗号:a,或(a,)
- 以逗号分隔项目:a, b, c or (a, b, c)
- 使用tuple()内建:tuple()或tuple(iterable)
对象方法
见Python容器
range
class range(start, stop[, step])
str
构造方法
class str(object=”)
单引号: ‘允许 嵌入 “一对” 双引号’。
双引号: “允许 嵌入 ‘一对’ 单引号”。
三引号:”’三个单引号”’,”“”三个双引号”“”。
对象方法
Python str字符串
Bytes
构造方法
classmethod bytes.fromhex(string)
classmethod bytearray.fromhex(string)
单引号 b’still allows embedded “double” quotes’
双引号: b”still allows embedded ‘single’ quotes”.
三引号: b”’3 single quotes”’, b”“”3 double quotes”“”
set
class set([iterable])
class frozenset([iterable])
dict
class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
构造方法
>>> a = dict(one=1, two=2, three=3)>>> b = {'one': 1, 'two': 2, 'three': 3}>>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))>>> d = dict([('two', 2), ('one', 1), ('three', 3)])>>> e = dict({'three': 3, 'one': 1, 'two': 2})>>> a == b == c == d == e----------classmethod fromkeys(seq[, value])
对象方法:
参考文献:
http://python.usyiyi.cn/translate/python_352/library/stdtypes.html#list
- Python 容器API
- 容器 API
- API 容器
- 容器API
- python容器
- python容器
- python 容器
- python容器
- 常用容器API
- python api
- map/multimap容器常用API
- python 容器排序
- Python基础2 容器
- PYTHON 容器TIPS
- 【Python】容器类
- python 容器的使用
- Python容器类型
- python 内置容器
- 《二》取消关注并删除用户信息
- ffplay中的parse_options()分析
- 远程连接服务器数据库报错:Host ‘XXXXXX’ is blocked because of many connection errors
- 【备忘】动力节点MySQL数据库视频 86集下载
- ReentrantLock源码解析
- Python 容器API
- Java中常用进制转换
- Lintcode 463 整数排序
- WPF架构分析
- Linux 内核文件系统关键数据结构
- KMP子字符串查找算法.java
- div中的内容垂直居中的五种方法
- Git版本控制使用方法入门教程
- 深度学习Java类库deeplearning4j 学习笔记-MNIST手写数字分类问题