为什么用writelines一直写不进去

白衣衣 2018-04-19 10:55:42
import os

def search_file(file_meun,file_name):
os.chdir(file_meun)

for each_file in os.listdir(os.curdir):
ext = os.path.splitext(each_file)[1]
if ext in file_name:
vedio_list.append(os.getcwd() + os.sep + each_file + os.linesep)
if os.path.isdir(each_file):
search_file(each_file,file_name)
os.chdir(os.pardir)

file_meun = input('请输入待查找的初始目录:')
file_name = ['.mp4','.rmvb','.avi']
vedio_list = []
search_file(file_meun,file_name)
f = open(os.getcwd() + os.sep + 'vediolist.txt','w')
f.writelines(vedio_list)
f.close
...全文
1094 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
白衣衣 2018-04-19
  • 打赏
  • 举报
回复
文件路径就是当前打开新建的 f 啊,当前目录下,文件已经新建出来了,只是没写入
oyljerry 2018-04-19
  • 打赏
  • 举报
回复
先看看写的文件路径,名称是不是有问题
白衣衣 2018-04-19
  • 打赏
  • 举报
回复
用print打印试过了不是空列表啊

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧