The disk method_usage of the shutil module
The disk_usage method of the shutil module is designed to display disk usage statistics for the specified path. The method returns a named tuple with the attributes total (total memory), used (used memory), and free (free memory).
Syntax
import shutil
shutil.disk_usage(path to folder)
Example
Let's find out the disk usage statistics for the dir folder:
import shutil
print(shutil.disk_usage('dir'))
The result of the executed code:
usage(total=1000068870144, used=808954097664, free=191114772480)
See also
-
method
statof moduleos,
which returns the status of the path -
method
path.getsizeof moduleos,
which returns the size of the path in bytes