'''先说个小技巧,help()在Python终端直接看东西比较麻烦,我习惯用把这些东西导出到文件中在看,将Python重定向即可,
import sys;sys.stdout=open('~/xxx.py','w') help(str);
str 内建函数总忘了,有哪些索性记录一下
'''
#指定多说一句,如果想要截取字字符串只用用切片就行了,s='123' '23'==s[1:],免得写多了类似Java或C++忘了这个东西,哈哈哈aaacccc
def capitalize(self):
"""
1 s.capitalize()
返回一个s的拷贝并使开头大写
"""
return ""
def center(self, width, fillchar=None):
"""
2 s.center(width[, fillchar])
返回以s为中心的长度为width字符串,不够的用fillchar填充,默认为空格
"""
return ""
def count(self, sub, start=None, end=None):
"""
3 S.count(sub[, start[, end]]) -> int
返回S中sub子字符串的个数,start开始位置, end结束位置
"""
return 0
def decode(self, encoding=None, errors=None):
"""
4 S.decode([encoding[,errors]]) -> object
s使用指定的编码解码,errors指定出错处理,不指定使用默认的方法
"""
return object()
def encode(self, encoding=None, errors=None):
"""
S.encode([encoding[,errors]]) -> object
S使用指定的编码编码.errors指定出错处理
"""
return object()
def endswith(self, suffix, start=None, end=None):
"""
S.endswith(suffix[, start[, end]]) -> bool
返回s是否以suffix结尾start 开始位置, end结束位置
"""
return False
def expandtabs(self, tabsize=None):
"""
S.expandtabs([tabsize]) -> string
返回一个字符串,设置这个字符串中的tab长度,默认长度为8
"""
return ""
def find(self, sub, start=None, end=None):
"""
S.find(sub [,start [,end]]) -> int
S中查找sub子字符串,找到返回第一个匹配子字符串的index,start起始位置,end结束位置
没有匹配项返回-1
"""
return 0
def format(self, *args, **kwargs):
"""
S.format(*args, **kwargs) -> string
格式化字符串
"""
pass
def index(self, sub, start=None, end=None):
"""
S.index(sub [,start [,end]]) -> int
和find()一样但是在没有匹配的时候抛出ValueError 异常
"""
return 0
def isalnum(self):
"""
S.isalnum() -> bool
是否都是数字和字母
"""
return False
def isalpha(self):
"""
S.isalpha() -> bool
都是字母
"""
return False
def isdigit(self):
"""
S.isdigit() -> bool
都是数字
"""
return False
def islower(self):
"""
S.islower() -> bool
都是小写字母(有数字也是FALSE)
"""
return False
def isspace(self):
"""
S.isspace() -> bool
纯空格
"""
return False
def istitle(self):
"""
S.istitle() -> bool
一个标题字符串
"""
return False
def isupper(self):
"""
S.isupper() -> bool
都是大写
"""
return False
def join(self, iterable): # real signature unknown; restored from __doc__
"""
S.join(iterable) -> string
返回一个用str将可迭代的参数添加到一个字符串中
"""
return ""
def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__
"""
S.ljust(width[, fillchar]) -> string
返回一个左边用fillcahr填充的字符串,默认空格
"""
return ""
def lower(self): # real signature unknown; restored from __doc__
"""
S.lower() -> string
全小写
"""
return ""
def lstrip(self, chars=None): # real signature unknown; restored from __doc__
"""
S.lstrip([chars]) -> string or unicode
返回去除左边chars的字符串,默认是空格
"""
return ""
def partition(self, sep):
"""
S.partition(sep) -> (head, sep, tail)
返回以sep分割的字符串元祖(头,sep, 尾)
"""
pass
def replace(self, old, new, count=None): # real signature unknown; restored from __doc__
"""
S.replace(old, new[, count]) -> string
字符串替换,count从开始数替换的次数,默认全部替换
"""
return ""
def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
"""
S.rfind(sub [,start [,end]]) -> int
右查找,返回index,没有返回-1
"""
return 0
def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
"""
r.rindex(sub [,start [,end]]) -> int
同上,没有抛出异常
"""
return 0
def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__
"""
S.rjust(width[, fillchar]) -> string
和左边那个一个意思
"""
return ""
def rpartition(self, sep): # real signature unknown; restored from __doc__
"""
S.rpartition(sep) -> (head, sep, tail)
略 上边的那个的右边方法
"""
pass
def rsplit(self, sep=None, maxsplit=None): # real signature unknown; restored from __doc__
"""
S.rsplit([sep [,maxsplit]]) -> list of strings
分割
"""
return []
def rstrip(self, chars=None): # real signature unknown; restored from __doc__
"""
S.rstrip([chars]) -> string or unicode
右边清除
"""
return ""
def split(self, sep=None, maxsplit=None): # real signature unknown; restored from __doc__
"""
S.split([sep [,maxsplit]]) -> list of strings
分割字符串成list,默认空格
"""
return []
def splitlines(self, keepends=False): # real signature unknown; restored from __doc__
"""
S.splitlines(keepends=False) -> list of strings
字符串分割成行用\r,\n,\r\n做标记分割
"""
return []
def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__
"""
S.startswith(prefix[, start[, end]]) -> bool
是不是以prefix开始的字符串
"""
return False
def strip(self, chars=None): # real signature unknown; restored from __doc__
"""
S.strip([chars]) -> string or unicode
2头清除
"""
return ""
def swapcase(self): # real signature unknown; restored from __doc__
"""
S.swapcase() -> string
大小写互换
"""
return ""
def title(self): # real signature unknown; restored from __doc__
"""
S.title() -> string
返回成标题样子
"abcd a la la land" -> "Abcd A La La Land"
"""
return ""
def translate(self, table, deletechars=None): # real signature unknown; restored from __doc__
"""
S.translate(table [,deletechars]) -> string
用table 做转换表, 并删除指定的部分(先删除后转换
用法
import string
table = string.maketrans('src', 'dist')
'src will be replaced'.translate(table) ->'dist will be repalced'
'src will be replaced'.translate(table, 'replaced') ->'dist will be '
'src will be replaced'.translate(table, 'src') ->' will be repalce'
"""
return ""
def upper(self): # real signature unknown; restored from __doc__
"""
S.upper() -> string
全变成大写
"""
return ""
def zfill(self, width): # real signature unknown; restored from __doc__
"""
S.zfill(width) -> string
0填充
"""
return ""
python str内建函数文档
最新推荐文章于 2019-12-25 17:17:21 发布