How to get result exactly the same format as follows?
result = ( C:\data\a.jpg C:\data\b.jpg C:\data\c.jpg )
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"
.)
您也可以尝试拆分反斜杠,如下所示:
person_names.add(image_path_names[-1].split('/')[0].split('\\')[1])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.