如何切片url?

问题描述 投票:0回答:1

我想从

https://exemple.com/key-system-1?hwid=07f8f20b7419f622&zone=Europe/Rome
中截取我的网址 到
hwid=07f8f20b7419f622

我试过了

url = "https://exemple.com/key-system-1?hwid=07f8f20b7419f622&zone=Europe/Rome"
uirl = url[: url.find("hwid")]
print (uirl)

但是结果是

https://exemple.com/key-system-1?
python slice
1个回答
0
投票
url = "https://exemple.com/key-system-1?hwid=07f8f20b7419f622&zone=Europe/Rome"
url_slice_1 = url[url.find("hwid"):]
url_slice_2 = url_slice_1[url_slice_1.find("&"):]
print (url_slice_2 )
© www.soinside.com 2019 - 2024. All rights reserved.