On this page
shutil.disk_usage
Prev: shutil.copytree | Up: shutil | Next: shutil.Error
Rel: shutil.chown, shutil.copy, shutil.copy2, shutil.copyfile
Ref: docs.python.org — shutil.disk_usage
Tags: #public #python3 #stdlib #shutil
Import
import shutil
from shutil import disk_usage
Signature & Overview
shutil.disk_usage(path)
Return disk usage statistics about the given path.
Usage
import shutil
usage = shutil.disk_usage(".")
assert usage.total >= usage.used and usage.free >= 0
Gotchas
- Returns bytes as a named tuple
(total, used, free): Divide by1024**3for GiB. - On Unix,
freeis space available to the current user: Because of reserved root blocks,used + freemay be slightly less thantotal.
REPL Inspect
from shutil import disk_usage
help(disk_usage)
Linked from
Related notes
- tuts/python3/stdlib_module/shutil/copytree Linked here; links to this page; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/Error Linked here; links to this page; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/shutil/chown Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copy Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copy2 Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copyfile Linked here; shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copyfileobj shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copymode shared tags: #shutil, #stdlib
- tuts/python3/stdlib_module/shutil/copystat shared tags: #shutil, #stdlib