想要获取invite_uuid=之后的那一串字符:
url = "http://www.baidu.com/public_share?rule_type=member&invite_uuid=72665347-35b1-4326-b37d-078d4f8f3f73&"
print (url.index("&"))
r1 =url[url.index("&")+1:-1]
print(r1)
r1.index('=')
print(r1[r1.index('=')+1:-1])
返回:72665347-35b1-4326-b37d-078d4f8f3f7
方法二:正则表达式:很好用
string = "xxxxxxxxxxxxxxxxxxxxxxxx entry '某某内容' for aaaaaaaaaaaaaaaaaa"
result = re.findall(".*entry(.*)for.*", string)
for x in result:
print(x)
》》》'某某内容'
但是此方法如果在string字符串中有多个,就只会取最后一个的