短視頻PHP源碼python批量獲取圖像路徑txt

#導入對路徑操作的庫
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章