Find free disk space in python on OS/X

后端 未结 7 1175
死守一世寂寞
死守一世寂寞 2020-12-08 07:51

I\'m looking for the number of free bytes on my HD, but have trouble doing so on python.

I\'ve tried the following:

import os

stat = os.statvfs(path         


        
7条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 08:07

    In python 3.3 and above shutil provides you the same feature

    >>> import shutil
    >>> shutil.disk_usage("/")
    usage(total=488008343552, used=202575314944, free=260620050432)
    >>> 
    

提交回复
热议问题