Blog
Blog copied to clipboard
Python 基本数据类型
Python 基本数据类型
Python 基本数据类型:
- Number 数字
- String 字符串
- List 列表
- Tuple 元组
- Dictionary 字典
Number 数字
Python3 支持的数字类型:
- int
- float
- bool
- complex
常用函数:
- abs()
- divmod()
- pow()
- round()
- sum()
- hex()
- oct()
- chr()
- ord()
String 字符串
大小写字母
- str.lower()
- str.upper()
- str.swapcase()
- str.capitalize()
字符对齐
- str.ljust()
- str.rjust()
- str.center()
- str.zfill()
字符查找
- str.find()
- str.index()
- str.count()
字符替换
- str.strip()
- str.replace()
- str.translate()
字符分割和组合
- str.split()
- str.splitlines()
- str.join()
编码和解码
- str.encode()
- str.decode()
字符判断
- str.startswith()
- str.endswith()
- str.isalnum()
- str.isalpha()
- str.isdigit()
- str.islower()
- str.isupper()
详细参考:
help(str)
List 列表
- len()
- min()
- max()
- cmp()
- L.append()
- L.extend()
- L.count()
- L.index()
- L.insert()
- L.pop()
- L.remove()
- L.reverse()
- L.sort()
详细参考:
help(list)
Tuple 元组
- T.count()
- T.index()
- min()
- max()
- len()
- cmp()
Sets 集合
- S.add()
- S.difference()
- S.discard()
- S.intersection()
- S.pop()
- S.remove()
- S.union()
- S.update()
详细参考:
help(set)
Dictionary 字典
- D.get()
- D.items()
- D.keys()
- D.values()
- D.setdefault()
详细参考:
help(dict)