so this is my first python experience. I have a list of images in folder that I’m trying to convert to html pages. For that I have the following code:
import inspect, os, errno, markup
path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))+'/www/img/'
print path
for f in os.listdir(path):
counter = 1
page = markup.page()
page.init(charset="UTF-8")
from markup import oneliner as e
page.a(e.img(src='img/'+f, width=1024, height=768), href='')
final = open('/index'+str(counter)+'.html','w')
final.write(page)
and I get an IOError: [Errno 13] Permission denied: '/index1.html' message….
any clues or ideas are much appreciated. thanks!
Your problem is here:
open('/index'+str(counter)+'.html','w')The path starting with ‘/’ is an absolute path, no matter what’s your current directory.
And it’s not a python specific.