您好,登錄后才能下訂單哦!
>>>dir(str)
['__add__','__class__', '__contains__', '__delattr__', '__doc__', '__eq__',
format__','__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__
slice__','__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '_
d__', '__mul__','__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr_
'__rmod__', '__rmul__', '__setattr__','__sizeof__', '__str__', '__subclassh
__','_formatter_field_name_split', '_formatter_parser', 'capitalize', 'cente
'count', 'decode', 'encode', 'endswith','expandtabs', 'find', 'format', 'in
', 'isalnum','isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper
'join', 'ljust','lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex'
rjust','rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith'
strip','swapcase', 'title', 'translate', 'upper', 'zfill']
>>> name= "dick"
>>>name.capitalize()
'Dick'
>>>name.center(20)
' dick '
>>>name.center(20,'**')
'********dick********'
>>> name
'dick'
>>>name[0:1]
'd'
>>> name= 'hdwquhnjdoiwqjdwqdiuewmdpoewkdpwqdkkmwqpodwq'
>>>name.count('s')
0
>>>name.count('w')
8
>>>name.count('w',0,10)
1
>>> name= 'alax'
>>>name[0:2]
'al'
>>>name.count('a',0,2)
1
>>>
>>> '胡偉'
'\xba\xfa\xce\xb0'
>>> str1= '\xba\xfa\xce\xb0'
>>>print str1
胡偉
>>>str1.decode('gbk')
u'\u80e1\u4f1f'
>>>str1.decode('gbk').encode('utf-8')
'\xe8\x83\xa1\xe4\xbc\x9f'
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。