赞
踩
已知一个url字符串,对其进行切割
1.以“,”进行切割
>>> a='https://baike.baidu.com/item/%E5%85%83%E5%AE%B5%E8%8A%82/118213?fr=aladdin#1'
>>> b=a.split(".")
>>> print(b)
['https://baike', 'baidu', 'com/item/%E5%85%83%E5%AE%B5%E8%8A%82/118213?fr=aladdin#1']
2.以“/”进行切割
>>> a= "http://www.baidu.com/python/image/123456.jpg"
>>> b=a.split("/")
>>> print(b)
['http:', '', 'www.baidu.com', 'python', 'image', '123456.jpg']
>>>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。