-1

我有这个网址:

https://www.yoursite.com/drive/team-real-431/pepe-ozil-R323/anyway-jim-james-hi-bye-hi-321312/;jsessionid=DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33

我希望有

DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33

我试过

ulrJS = "https://www.yoursite.com/drive/team-real-431/pepe-ozil-R323/anyway-jim-james-hi-bye-hi-321312/;jsessionid=DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33"
ulrJS = ulrJS.split('/')[-1]
4

2 回答 2

1

您可以使用urlparse

>>> import urlparse
>>> url = 'https://www.yoursite.com/drive/team-real-431/pepe-ozil-R323/anyway-jim-james-hi-bye-hi-321312/;jsessionid=DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33'
>>> url_parts = urlparse.urlparse(url)
>>> jsessionid = dict(urlparse.parse_qsl(url_parts.params)).get('jsessionid')
>>> print(jsessionid)
DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33
于 2016-04-27T08:52:57.217 回答
0
from urlparse import urlparse
url ="https://www.yoursite.com/drive/team-real-431/pepe-ozil-R323/anyway-jim-james-hi-bye-hi-321312/;jsessionid=DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33"
u = urlparse(url)
print u.params.split("=")[1]
'DBDE454034B0EE325FC100112EF2E123.56AC29295781342F53AB242D03EE33'
于 2016-04-27T08:57:22.997 回答