stcaac 发表于 2018-8-8 09:27:00

统计目录大小的python脚本

  统计目录大小的python脚本:
vi dirsize.py
  注:
  1、def为自定义函数,有返回值以return结束
  #!/usr/bin/python
  import os
  from os.path import join, getsize
  def getdirsize(dir):
  size = 0
  for root, dirs, files in os.walk(dir):
  size += sum()

  return>  if name == 'main':
  filesize = getdirsize('/tmp')
  print ('There are ' + str(filesize/1024/1024) + 'Mbytes in /tmp')
  :wq
python dirsize.py
页: [1]
查看完整版本: 统计目录大小的python脚本