当前第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怎么求整数n的阶乘?
Python怎么把列表转化为字符串
Python用什么文本编辑器
对Python中gensim库word2vec的使用
Python2.7和3.7的区别
Python基础知识一:网络通信数据传输
Python学完基础学什么
spyder和Python有什么关系
Python如何调用c语言函数的使用详解
Python如何实现自动访问网页功能
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 如何找到一个目录下所有.txt文件