| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
- print('===视频查询程序===')
 
 - import os
 
  
- def finvid(pth):
 
 -     os.chdir(pth)
 
 -     str1 = ''
 
  
-     for each_file in os.listdir(os.curdir):
 
 -         name,ext = os.path.splitext(each_file)
 
 -         if ext == '.mp4' or '.rmvb' or '.avi':
 
 -             str1 += (os.getcwd() + os.sep + each_file + '\n\n')
 
 -         if os.path.isdir(each_file):
 
 -             finvid(each_file)
 
 -             os.chdir(os.pardir)
 
 -     a = open('D:\\vedioList.txt','w',encoding='utf-8')
 
 -     a.write(str1)
 
 -     a.close()
 
  
 
- pth = input('请输入待查找的初始目录:')
 
 - finvid(pth)
 
 
  复制代码 
 
如代码,运行后txt文件中写进去的是文件夹中的每个文件的路径,并没有查找视频文件
- print('===视频查询程序===')
 
 - import os
 
  
- def finvid(pth):
 
 -     os.chdir(pth)
 
 -     str1 = ''
 
  
-     for each_file in os.listdir(os.curdir):
 
 -         name,ext = os.path.splitext(each_file)
 
 -         if ext == '.mp4' or ext == '.rmvb' or ext == '.avi':
 
 -             str1 += (os.getcwd() + os.sep + each_file + '\n\n')
 
 -         if os.path.isdir(each_file):
 
 -             finvid(each_file)
 
 -             os.chdir(os.pardir)
 
 -     a = open('D:\\vedioList.txt','w',encoding='utf-8')
 
 -     a.write(str1)
 
 -     a.close()
 
  
 
- pth = input('请输入待查找的初始目录:')
 
 - finvid(pth)
 
 
  复制代码 
 
 
 |   
 
 
 
 |