js脚本替换拼接图片路径

#js脚本,拼接图片路径

##替换拼接页面中图片路径:
-$(function () {
$(‘img’).each(function () {
var imgpath = $(this).attr(‘src’)
imgpath = “{% static '” + imgpath + “’ %}”
$(this).attr(‘src’, imgpath)
})

console.log($('body').html())

})

-python脚本把页面中点点/去掉的图片路径:
a=open(‘index.html’,‘r’,encoding=‘utf8’)
b=a.read()
print(b)
b=b.replace(‘src="…’,‘src="’)
print(b)
c=open(‘text.html’,“w”,encoding=‘utf8’)
c.write(b)

猜你喜欢

转载自blog.csdn.net/a_sleepingcat/article/details/83618185
今日推荐