例子:
#!/usr/bin/python name='1besdfgb' name = str('ab sabg fdfg@#') li = ['l','b','k','x','z','d','z'] intab = 'abcde' outtab = '12345' print(name.__contains__('g@'))# print('g@' in name)# print(name.capitalize())# print(name.capitalize().center(20,'*'))# print(name.count('a',0,3))# print(name.expandtabs(16))# print(len(name))# print(len(name.expandtabs(8)))# print(name.find('9')) # success 0 error -1 print(name.index('a')) list_1 = 'liukun {0} as {1}' print(list_1.format('Kamil','hero')) print(''.join(li)) print('_'.join(li)) print(name.lower())# xiaoxie #trantab = maketrans(intab,outtab) #print(name.translate(trantab,'fg')) print(name.partition('sa'))#fengge
True True Ab sabg fdfg@# ***Ab sabg fdfg@#*** 1 ab sabg fdfg@# 14 22 -1 0 liukun Kamil as hero lbkxzdz l_b_k_x_z_d_z ab sabg fdfg@# ('ab ', 'sa', 'bg fdfg@#')