How to get result exactly the same format as follows?
result = ( C:\data\a.jpg C:\data\b.jpg C:\data\c.jpg )
The following code fails:
import glob
files = glob.glob ('*.jpg')
for file in files:result = "C:\data\" + file
How to get result exactly the same format as follows?
result = ( C:\data\a.jpg C:\data\b.jpg C:\data\c.jpg )
The following code fails:
import glob
files = glob.glob ('*.jpg')
for file in files:result = "C:\data\" + file
import os, glob
files = glob.glob('*.jpg')
files = [os.path.join("C:\\data", file) for file in files]
result = "( " + " ".join(files) + " )"
print result # Prints ( C:\data\a.jpg C:\data\b.jpg C:\data\c.jpg )
(You might want to use os.getcwd()
rather than the literal "C:\\data"
.)