|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 takehsi 于 2017-12-8 09:04 编辑
比如列表中url为 ↓
http://www.xxx.com/index.php?id=1
www.xxx.com/index.php?id=1
http://www.xxx.com/index.php/xxx/xxx/xx?id=1
这三种怎么把url切成 ↓
http://www.xxx.com
www.xxx.com
'''
这种情况http://www.xxx.com/index.php?id=1
if 怎么判断前面有http://
怎么从第3个斜线开始切?
'''
'''
这种情况www.xxx.com/index.php?id=1
怎么从第1个斜线开始切?
'''
'''
http://www.xxx.com/index.php/xxx/xxx/xx?id=1
这种怎么切啊??
'''
'''
www.xxx.com/index.php/xxx/xxx/xx?id=1
还有这种
'''
希望各位大神老师帮忙,先谢了!!!
- test = r"http://www.xxx.com/index.php?id=1"
- tar = r'/index'
- s = test.split(tar)
- print(s[0])
复制代码
|
|