码迷,mamicode.com
首页 > 编程语言 > 详细

python_str

时间:2016-07-09 12:06:41      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

str.capitalize() 首字母大写,其他小写

str.center(width[, fillchar])

  Return centered in a string of length width. Padding is done using the specified fillchar(default is a space).

str.count(sub[, start[, end]]) 统计sub的个数

技术分享

str.encode([encoding[, errors]]) 和str.decode([encoding[, errors]]) 编解码

str.endswith(suffix[, start[, end]]) 判断是否以suffix结尾

  str.startswith(prefix[, start[, end]])

技术分享

str.find(sub[, start[, end]])查找sub的位置(仅在需要知道sub位置时使用)和str.index(sub[, start[, end]])(多用in方法代替)

str.rfind(sub[, start[, end]]) 和str.rindex(sub[, start[, end]]) 返回最大指数

str.format(*args, **kwargs)

技术分享

str.isalnum() 判定是否是数字和字母

str.isalpha() 判定是否是字母

str.isdigit() 判定是否是数字

str.islower() 和str.isupper() 判定是否是小写和大写

str.isspace() 判定是否是空格

str.istitle() 判定是否是标题(即单词首字母大写)【str.title() 】

str.join(iterable) 在iterable的元素中插入str

技术分享

 str.ljust(width[, fillchar]) 左对齐调整长度(<= len(s),仍输出str)

技术分享

str.rjust(width[, fillchar]) 右对齐

 技术分享

str.zfill(width) 左填0补齐

技术分享

str.lower() 转化为小写和str.upper() 转化为大写

str.lstrip([chars]) 和str.rstrip([chars]) 及str.strip([chars]) 删除字符

str.translate(table[, deletechars]) 删除某些元素

 技术分享

str.replace(old, new[, count]) 替换

 技术分享

 

str.partition(sep) 和str.rpartition(sep)

 技术分享

str.rsplit([sep[, maxsplit]]) 和str.split([sep[, maxsplit]])

str.swapcase() 大小写互换

 

python_str

标签:

原文地址:http://www.cnblogs.com/sxbjdl/p/5655445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!