I'm trying to loop through only the csv files in a folder that contains many kinds of files and many folders, I just want it to list all of the .csv files in this folder.
Here's what I mean:
import os, sys
path = "path/to/dir"
dirs = os.listdir(path)
for file in dirs:
if file == '*.csv':
print file
I know there is no wildcard variable in python, but is there a way of doing this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…