【发布时间】:2018-01-29 17:48:34
【问题描述】:
我试图只获取文件夹中的文件,不包括任何其他目录。但下面的脚本正在将所有文件和文件夹移动到另一个目录。
while True:
# Go through each of the directories
for mylist in dirlist:
check_dir = mylist[0]
callback = mylist[1]
# get the list of files in the directory
filelist = os.listdir(check_dir)
for this_file in filelist:
if ((this_file == ".") or (this_file == "..") or (this_file == "donecsvfiles") or (this_file == "doneringofiles")):
print "Skipping self and parent"
continue
full_filename = "%s/%s"%(check_dir, this_file)
【问题讨论】:
-
您是否还希望将子目录中的文件(如果有)包含在列表中?
-
不,只是文件