TypeError: expected str, bytes or os.PathLike object, not generator

TypeError: expected str, bytes or os.PathLike object, not generator

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re


path=r"\\192.168.55.73\Team-CV\dataset\origin_all_datas_0807"

directory= os.walk(path)
ext='jpg|jpeg|bmp|png|ppm'


for root, dirs, files in os.walk(directory):
    print(files)

原因:directory已经调用过os.walk了,再调用一遍os.walk(directory)就会出现这个异常。

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/81543355