第二章 内置数据类型¶
Python 支持一种数据结构的基本概念,名为容器(container),容器基本上就是可包含其他对象的对象。有三种主要的容器:序列(如列表和元组)、映射(如字典)和集合(set)。在序列中,每个元素都有编号,而在映射中,每个元素都有名称(也叫键)和值。
- 数据类型
- 数字(整数、浮点数、复数)
- 序列 (字符串、元组、列表)
- 通用的序列操作
- 字典 - 映射类型
- 集合
- 字符串方法
- str.casefold()
- str.center(width[, fillchar])
- str.count(sub[, start[, end]])
- str.endswith(suffix[, start[, end]])
- str.expandtabs(tabsize=8)
- str.find(sub[, start[, end]])
- str.format(*args, **kwargs)
- str.is()
- str.join(iterable)
- str.lower()
- str.partition(sep)
- str.replace(old, new[, count])
- str.split(sep=None, maxsplit=-1)
- str.splitlines([keepends])
- str.strip([chars])
- str.zfill(width)
- 列表与元组方法
- 字典方法
- 集合方法
- set.add(elem)
- set.clear()
- set.copy()
- set.difference(*others)
- set.difference_update(*others)
- set.discard(elem)
- set.intersection(*others)
- set.intersection_update(*others)
- set.isdisjoint(other)
- set.issubset(other)
- set.issuperset(other)
- set.pop()
- set.remove(elem)
- set.symmetric_difference(other)
- set.symmetric_difference_update(other)
- set.union(*others)
- set.update(*others)
- 内置函数
- abs(x)
- all(iterable)
- any(iterable)
- bin(x)
- class bool([x])
- chr(i)
- compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
- delattr(object, name)
- class dict(**kwarg)
- dir([object])
- divmod(a, b)
- enumerate(iterable, start=0)
- eval(expression[, globals[, locals]])
- exec(object[, globals[, locals]])
- filter(function, iterable)
- class float([x])
- format(value[, format_spec])
- getattr(object, name[, default])
- globals()
- hasattr(object, name)
- hash(object)
- help([object])
- hex(x)
- id(object)
- input([prompt])
- class int(x, base=10)
- isinstance(object, classinfo)
- issubclass(class, classinfo)
- iter(object[, sentinel])
- len(s)
- class list([iterable])
- locals()
- map(function, iterable, …)
- max(iterable, *[, key, default])
- min(iterable, *[, key, default])
- next(iterator[, default])
- oct(x)
- open()
- ord(c)
- pow(base, exp[, mod])
- print(*objects, sep=’ ‘, end=’n’, file=sys.stdout, flush=False)
- class range(start, stop[, step])
- reversed(seq)
- round(number[, ndigits])
- class set([iterable])
- setattr(object, name, value)
- class slice(start, stop[, step])
- sorted(iterable, *, key=None, reverse=False)
- @staticmethod
- class str(object=b’’, encoding=’utf-8’, errors=’strict’)
- sum(iterable, /, start=0)
- super([type[, object-or-type]])
- class tuple([iterable])
- class type(name, bases, dict)
- vars([object])
- zip(*iterables)