usage of file separator

D

devnew

in my code i am iterating thru a list of filenames (like 'image1.jpg'
etc) and appending them to fully qualified directory names

for x in imagefilenames:
imgfile=folder+"/"+x
newimgfilenamelist.append(imgfile)

sothat finally i can get items like c:/mycode/image1.jpg etc from the
newimgfilenamelist

on windows this will work..but how do i make it work on other os?
Being a beginner i couldn't figure out how to solve this using
os.path can anyone help?

sorry if this is a silly qn
dn
 
T

Thomas Wittek

(e-mail address removed):
for x in imagefilenames:
imgfile=folder+"/"+x
newimgfilenamelist.append(imgfile)

[..] how do i make it work on other os?

from os.path import join
#..
imgfile=join(folder, x)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top