Hello,World!

允许我以这么简陋的几个代码,开始技术博客。嘻嘻

需求:FTP上有一堆堆的文件,需要拉下来得到文件的创建日期并进行排序。

方法:小白一枚,在网上找到了os模块的文档,试着写了一几行。把这问题解决了,并顺便优化了一下输出格式。

#!/usr/bin/python 
# -*- coding: utf-8 -*-
import os
filePath = os.getcwd()

for root, dirs, files in os.walk(filePath):
    for name in files:
#发现文件名很多作废了的,为了加快速度加入一个筛选机制
        if "" in name:
            break
        if ".DS_Store" in name:
            break
#这一行打开为输出文件路径和文件名
#        print(os.path.join(root, name))
#这一行打开为仅输出文件名
        print(os.path.join(name))
#这个代码块不知道干嘛用的
#for name in dirs:
#        print(os.path.join(root, name))
#
print ("文件爬取完毕,按任意键退出~~")
os.system("pause")

==========

以上!快乐的小黄回去搬砖啦。目标是开上全自动挖掘机~

posted on 2019-07-16 14:28  海底浪张  阅读(260)  评论(0)    收藏  举报