do_dir.py 469 B

12345678910111213141516
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from datetime import datetime
  4. import os
  5. pwd = os.path.abspath('.')
  6. print(' Size Last Modified Name')
  7. print('------------------------------------------------------------')
  8. for f in os.listdir(pwd):
  9. fsize = os.path.getsize(f)
  10. mtime = datetime.fromtimestamp(os.path.getmtime(f)).strftime('%Y-%m-%d %H:%M')
  11. flag = '/' if os.path.isdir(f) else ''
  12. print('%10d %s %s%s' % (fsize, mtime, f, flag))