python url拼接代码

Python08

python url拼接代码,第1张

方法来自网络,保存以便以后自用。

经测试可正确拼接下列形式

base1 = ' http://www.bagtree.com/'url1 = '../../themes/bagtree_2011/images/pinzhi.gif'

base2 = ' http://info.ceo.hc360.com/list/qygl-ldl.shtml'url2 = '/2011/11/250020188368.shtml'

base3 = ' http://info.ceo.hc360.com/2012/07/190833206838.shtml'url3 = '190833206838-2.shtml'

1_url = " https://pvp.qq.com/web201605/ "

2_url="/herodetail/531.shtml"

add_url =" https://pvp.qq.com/web201605/herodetail/531.shtml "

运行这个for循环的时候,你的line_new 只是一个字符串 '30313030313030310000284f00000001.xml' 

循环遍历这个字符串的话,xml_name就相当于是字符串内的每一个字符 。

你应该新建一个 list, 在构建 line_new之后把每一个 line_new加到list里,在这里遍历这个list 来判断其中匹配的路径

你好,你可以先将uuid1处理成纯粹的字符,然后在进行拼接。

uid = str(uuid.uuid1())

suid = ''.join(uid.split('-'))