代码实现不了
import os
def search_file(dir_name):
f=open('vediolist.txt','w')
os.chdir(dir_name)
all_files=os.listdir(os.curdir)
for each_file in all_files:
if os.path.isfile(each_file):
ext=os.path.splitext(each_file)
if ext=='mp4'or ext=='rmvb'or ext=='avi':
f.write(os.getcwd()+os.seq+each_file)
if os.path.isdir(each_file):
search_file(each_file)
os.chdir(os.pardir)
dir_name=input('请输入需要检索的路径:')
search_file(dir_name)
顺便问一句发帖有限制吗? 我问题这么多,会不会很快就用完发帖次数? 没有你说的错误,我修改了一下,可能运行了。
import os
def search_file(dir_name):
os.chdir(dir_name)
all_files=os.listdir(os.curdir)
for each_file in all_files:
if os.path.isfile(each_file):
ext=os.path.splitext(each_file)
if ext=='.mp4'or ext=='.rmvb'or ext=='.avi':
f.write(os.getcwd()+os.sep+each_file + '\n')
if os.path.isdir(each_file):
search_file(each_file)
os.chdir(os.pardir)
dir_name=input('请输入需要检索的路径:')
f=open('vediolist.txt','w')
search_file(dir_name)
f.close()
页:
[1]