Need the path for particular files using os.walk()

前端 未结 3 1939
独厮守ぢ
独厮守ぢ 2020-12-25 12:27

I\'m trying to perform some geoprocessing. My task is to locate all shapefiles within a directory, and then find the full path name for that shapefile within the directory.

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 12:43

    Why not import glob ?

    import glob 
    
    print(glob.glob('F:\OTHERS\PHOTOS\Panama\\mai13*\\*.jpg') )
    

    and i get all the jpeg i want, with absolute path

    >>> 
    ['F:\\OTHERS\\PHOTOS\\Panama\\mai13\\03052013271.jpg', 
    'F:\\OTHERS\\PHOTOS\\Panama\\mai13\\05052013272.jpg', 
    'F:\\OTHERS\\PHOTOS\\Panama\\mai13\\05052013273.jpg']
    

提交回复
热议问题