取一个字符串的所有靠近前面的大写字母

比如有这样的字符串


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 

 

posted @ 2018-04-25 16:27  淋哥  阅读(543)  评论(0编辑  收藏  举报