当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import os
root = "H:\\ab123"
def findtxt(path, ret):
"" "Finding the *.txt file in specify path" ""
filelist = os.listdir(path)
for filename in filelist:
de_path = os.path.join(path, filename)
if os.path.isfile(de_path):
if de_path.endswith( ".txt" ): #Specify to find the txt file.
ret.append(de_path)
else :
findtxt(de_path, ret)
ret = []
findtxt(root, ret)
for path in ret:
print (path)
|
以上就是如何找到一个目录下所有.txt文件的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python的五个特点
Python怎么排序列表
Python阶乘求和的方法
Python可以用来干什么?
怎么安装Python包
ubuntu怎么安装Python
Python 拷贝特定后缀名文件,并保留原始目录结构的实例
linux下修改Python命令的方法示例(附代码)
Python中print与return区别
Python中如何安装pip
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 如何找到一个目录下所有.txt文件