How to embed html page saved in folder using href in python script
Re-assembly:
so currently I have
imagepath = os.join.path (currentdirectory, fruit, size, fruitproperty + ".html")
Now I want to insert this path into the following code:
htmlfile.write('<a href = imagepath > '+fruitproperty+' </a><br>\n')
so my problem is how to insert the image path into it? I tried different ways but didn't work.
+3
source to share
1 answer
You can use string.format
, example -
imagepath = os.join.path (currentdirectory, fruit, size, fruitproperty + ".html")
htmlfile.write(('<a href = {imagepath} > '+fruitproperty+' </a><br>\n').format(imagepath = imagepath))
Here, imagepath
inside {}
(curly braces) will be replaced with the value for the image path.
0
source to share