>>>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‘