美文网首页
python find查找制定字符

python find查找制定字符

作者: 戒灵 | 来源:发表于2018-10-31 11:58 被阅读0次
url='https://www.amazon.com/Amazon-Fire-TV-Stick-With-Alexa-Voice-Remote-Streaming-Media-Player/dp/B00ZV9RDKK/ref=zg_bs_electronics_1?_encoding=UTF8&psc=1&refRID=3RE1Q3RPWH4FJZP7VVAN'
index = url.find('/dp/')
print(index)
asin = url[url.find('/dp/'):]#查找/dp/之后
url1='https://www.amazon.com'+asin
asin1=url1[:url1.find('/ref')]#查找/ref之前
print(asin1)

运行结果为:https://www.amazon.com/dp/B00ZV9RDKK

相关文章

网友评论

      本文标题:python find查找制定字符

      本文链接:https://www.haomeiwen.com/subject/nytatqtx.html