Python 变量类型自带函数介绍
来源:互联网 发布:知乎法国婆婆 编辑:程序博客网 时间:2024/06/06 03:15
string
isalnum():当string全部为字母数字的时候返回True。islower():当string全部字母都为小写时返回True。isspace():当string全部为空白字符的时候返回True。isupper():当string全部字母都为大写时返回True。join(seq):seq必须是字符串的序列参数,以string为分隔符连接seq。lower():返回string的小写形式。upper():返回string的大写形式。replace(old,new[,count]):将string中的old替换成new,如果count不给,就是替换全部,如果给了count,就是替换前count个匹配结果。split([seq[,maxsplit]]):和别的语言用法一样,如果不写参数,默认分隔符为空格。translate(table[,delechars]):配合maketrans使用,第二个参数用来移除string中出现在delechars的字符。例子如下:
fromstringimportmaketrans # 引用 maketrans 函数。
intab ="aeiou"
outtab ="12345"
trantab = maketrans(intab, outtab)
str ="this is string example....wow!!!";
printstr.translate(trantab);
输出如下:th3s3s str3ng2x1mpl2....w4w!!!
find(sub[,start[,end]]):找到sub返回sub位置,否则返回-1。index(sub[,start[,end]]):类似find,但是找不到sub的时候会抛出ValueError。startswith(str, beg=0,end=len(string)):匹配开头,成功返回True。endswith(str, beg=0,end=len(string)):匹配结尾,成功返回True。strip([chars]):chars给出,则移除string两端中在chars出现的字符,默认移除两端空格。count(sub[,start[,end]]):统计string中sub出现的次数。 list
sort():给list排序reverse():翻转listappend(list2):在list后面添加元素index(a):在list中找到a的位置。
0 0
- Python 变量类型自带函数介绍
- string类型自带的函数
- Axure7.0自带的变量和函数有哪些?
- python isinstance函数判断变量类型
- MarkDown自带介绍
- <STL初探>list节点为自定义类型,如何访问节点中变量和函数,如何使用list自带的排序
- python 列表类(list)自带函数
- linux shell自带变量
- JS自带函数
- 各种自带函数
- JS自带函数
- JS自带函数
- js自带函数
- js自带函数
- mysql自带函数
- Unity自带函数
- zabbix自带触发器介绍
- JDK自带注解介绍
- Python List 、 tuple和dict
- epoll的理解
- Android开发之使用MediaRecorder录制视频
- Set Matrix Zeroes
- 九度OJ 1360:乐透之猜数游戏 (递归)
- Python 变量类型自带函数介绍
- Using Oracle SQL Developer to Setup SQL*Loader Runs
- 安卓学习笔记
- 1004. 成绩排名
- 深入理解IIS的多线程工作机制--学习了
- Python 常用模块使用
- Maven学习六:搭建多模块企业级项目
- NAT模式下,虚拟机ping通宿主,宿主无法ping通虚拟机
- js监听浏览器关闭事件