1. 程式人生 > >Python 遍歷資料夾裡面的內容 5*

Python 遍歷資料夾裡面的內容 5*


root_path='./result'
sub_path=root_path+'./tmp'
for root, dirs, files in os.walk(sub_path):
    for file in files:
        if os.path.splitext(file)[1] == '.jpg':  
            print(file)
            #print(os.path.splitext(file))