python批量获取图像路径txt

note:

#导入对路径操作的库
import sys
import os 

#图像路径
root_path = 'home/ll/'
#将每个图像的路径保存为txt
fns = os.listdir(root_path)
with open('image_list.txt', 'w') as f:
    for fn in fns:
        path = os.path.join(root_path, fn)
        f.wirte('{}\n'.format(path))
        print path

猜你喜欢

转载自blog.csdn.net/m0_37477175/article/details/79377147