Python序列类型操作符和内建方法
2016-06-13 15:00
423 查看
序列类型操作符和内键方法如下:
未完。。。
操作符 | 简介 | 例子 |
---|---|---|
append() | 向list后面添加数据 | list.append(‘fuck’) |
capitalize() | 把字符串第一个字母变大写,其余变小写 | str.capitalize() |
center() | 指定字符串长度,返回字符串居中,其他字符串填充(默认空格) | str.center(40,’a’) |
chr() | 返回指定ascii码表对应的字符 | chr(97) |
ord() | 返回指定字符对应的ascii码表 | ord(‘a’) |
cmp() | 比较大小,前一个比较大时返回1,反之,则返回-1,一样就返回0 | cmp(‘a’,’c’) |
count(str,start,end) | 查找字符串出现次数,start和end为始末数 | str.count(‘a’,1,8) |
encode() | 指定转换编码格式,第一个为编码格式,其次为默认值strict错误提示 | str.encode(‘base64’,’strict’) |
decode() | 指定编码格式的解码 | str.decode(‘base64’,’strict’) |
endswith() | 判断是否为指定字符串结尾,参数为指定字符串,开始和结束值 | str.endswith(‘abc’,6,9) |
expandtabs() | 转换tap(\t)的默认空格 | str.expandtabs(16) |
extend() | 在list后面追加其他list的值 | list.extend(list1) |
find() | 检查字符串中包含指定字符串,如果有返回索引值,反之返回-1 | str.find(‘abc’,0,len(str)) |
hex() | 把十进制转换为16进制 | hex(20) |
index() | 查找字符串或者list是否含有指定值 | list.endex(‘abc’,0,len(list)) |
insert() | 向list指定索引插入数据 | list.insert(6,’fuck’) |
isdecimal() | 查看字符串是否只包含十进制 | str.isdecimal() |
isdigit() | 检查字符串是否只由数字组成 | str.isdigt() |
islower() | 检查字符串是否只含小写字母 | str.islower() |
isnumberic() | 检查字符串是否只含数字 | str.isnumberic() |
isspace() | 检查字符串是否只含空格 | str.isspace() |
istitle() | 检查字符串的单词首字母是否都为大写 | str.istitle() |
isupper() | 检查字符串里字母所有都是大写 | str.isupper() |
join() | 将序列中指定字符连接生成新字符串 | ‘+’.join(list)或者’+’.join(tuple) |
len() | 查看序列或者字符串的长度 | len(list) |
list() | 转换为list格式 | list(tuple) |
ljust() | 让字符串左对齐,指定长度,向右填充 | str.ljust(40,’a’) |
rjust() | 让字符串右对齐,指定长度,向左填充 | str.rjust(40,’a’) |
lower() | 把字符串转换为小写 | str.lower() |
upper() | 把字符串转换为大写 | str.upper() |
lstrip() | 用来截起左边的空格或者指定字符 | ‘888lock’.lstrip(‘8’) |
rstrip() | 用来截去右边的空格或者指定字符 | ‘lock ‘.rstrip() |
max() | 返回字符串中最大的字符或者返回列表中最大的序列 | max(list) |
min() | 返回字符串中最小的字符或者返回列表中最小的序列 | min(str) |
oct() | 把十进制转换为八进制 | oct(8) |
zfill() | 返回指定长度的字符,右对齐,左填充‘0’ | str.zfill(50) |
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法