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

Posted 夜雨声烦

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 获取指定文件夹下所以文件相关的知识,希望对你有一定的参考价值。

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 获取指定文件夹下所以文件的主要内容,如果未能解决你的问题,请参考以下文章