类型 str 属性、方法列表
str | 注释 | 举列 (s='abcdef') |
__len__ | 串长 len(s) | s.__len__()=6 |
__iter__ | 迭代器 | for i in s.__iter__():print(i) #逐个列印串的字符 |
__getitem__ | 索引串的字符 s[i] | s.__getitem__(-1) # ’f' s.__getitem__(5) # ’f',索引号<len(s) |
__contains__ | 是否包含某字符 | s.__contains__('a') # True s.__contains__('g') # False |
capitalize | ||
casefold | ||
center | ||
count | ||
encode | ||
endswith | ||
expandtabs | ||
find | ||
format | ||
format_map | ||
index | ||
isalnum | ||
isalpha | ||
isascii | ||
isdecimal | ||
isdigit | ||
isidentifier | ||
islower | ||
isnumeric | ||
isprintable | ||
isspace | ||
istitle | ||
isupper | ||
join | ||
ljust | ||
lower | ||
lstrip | ||
maketrans | ||
partition | ||
replace | ||
rfind | ||
rindex | ||
rjust | ||
rpartition | ||
rsplit | ||
rstrip | ||
split | ||
splitlines | ||
startswith | ||
strip | ||
swapcase | ||
title | ||
translate | ||
upper | ||
zfill | ||
__add__ | 类同int数据类型的,以下都是 | |
__class__ | ||
__delattr__ | ||
__dir__ | ||
__doc__ | ||
__eq__ | ||
__format__ | ||
__ge__ | ||
__getattribute__ | ||
__getnewargs__ | ||
__gt__ | ||
__hash__ | ||
__init__ | ||
__init_subclass__ | ||
__le__ | ||
__lt__ | ||
__mod__ | ||
__mul__ | ||
__ne__ | ||
__new__ | ||
__reduce__ | ||
__reduce_ex__ | ||
__repr__ | ||
__rmod__ | ||
__rmul__ | ||
__setattr__ | ||
__sizeof__ | ||
__str__ | ||
__subclasshook__ | ||