Last active
December 20, 2019 14:54
-
-
Save NicHub/b7876284546196ac0968c84426707511 to your computer and use it in GitHub Desktop.
Get disk space in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Display disk stats | |
""" | |
import shutil | |
total, used, free = shutil.disk_usage("/") | |
print("DISK SPACE") | |
print(f"Total : {total:>16} B = { total // (2**30):>4} GiB" ) | |
print(f"Used : {used:>16} B = { used // (2**30):>4} GiB" ) | |
print(f"Free : {free:>16} B = { free // (2**30):>4} GiB" ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment