码迷,mamicode.com
首页 > 编程语言 > 详细

python 获取指定文件夹下所以文件

时间:2018-11-04 11:05:33      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:def   一个   self   排序   dir   mat   pat   port   report   

reportPath =文件夹路径
listdir=以一个list返回文件夹下所以文件

dirs = os.listdir(reportPath)
print(dirs)


def __get_report(self):
"""获取最新测试报告"""
dirs = os.listdir(reportPath)
# print(dirs)
dirs.sort() #列表排序
newreportname = dirs[-1]
print(‘The new report name: {0}‘.format(newreportname))
return newreportname

python 获取指定文件夹下所以文件

标签:def   一个   self   排序   dir   mat   pat   port   report   

原文地址:https://www.cnblogs.com/mahaining/p/9902992.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!