代码如下:
def func():
url = 'http://duoceshi.cn:7076/share/index.html?shareVideoId=-721509&playType=1'
dict1={}
parms = [i for i in url.split('?')]
dict1['协议'] = parms[0].split(':')[0]
dict1['多测师域名'] = parms[0].split('//')[1].split(':')[0]
dict1['端口'] = parms[0].split(':')[2].split('/')[0]
dict1['路径'] = parms[0].split('7076')[1]
for j in parms[1].split('&'):
a = j.split('=')
dict1[a[0]]=a[1]
print(dict1)
func()
输出结果如下:
{'协议': 'http', '多测师域名': 'duoceshi.cn', '端口': '7076', '路径': '/share/index.html',
'shareVideoId': '-721509', 'playType': '1'}