比如有这样的字符串
TWO INDUSTRIAL STYLE WALL LIGHTS also a ceramic figure of a cobbler and a group of minor pictures
希望得到的是: TWO INDUSTRIAL STYLE WALL LIGHTS
直接上代码
aa = "NINE CARAT GOLD GARNET RING AND ANOTHER GOLD RING Along with a gold and sapphire set pendant on chain, pearl and diamond set pend " aa1 = aa.replace(' ','=') ii = 0 for i in aa1: result = i.islower() print result if 'al' in str(result): ii = ii + 1 else: if 'rue' in str(result): break
if '=' in str(aa1[-2]):
item_name = item_desc[:ii - 1]
else:
item_name = item_desc[:ii]
print item_name