代码:

import os
import sys
def showsmallfiles(dir):
    v=os.listdir(dir)
    for i in v:
        d="%s/%s"% (dir,i)
        if os.path.isdir(d):
            showsmallfiles(d)
        else:
            if os.path.getsize(d) < int(sys.argv[2]):
                logger(d)

#logfile
def logger(text):
    f=open('d:/python/log.txt','a')
    f.write(text+'\r\n')
    f.close()

if len(sys.argv)<3:
    print('arguments is invalid')
    sys.exit()

showsmallfiles(sys.argv[1])

调用方式:

python listsmallfile.py d:/python 1000

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-06-25
  • 2022-01-15
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-07-26
相关资源
相似解决方案