Q5
How do you check disk usage using `shutil.disk_usage()`?
💬Answer
shutil.disk_usage(path) returns a named tuple containing total, used, and free bytes on the given path.
import shutil
total, used, free = shutil.disk_usage("/")
print(f"Used Space: {used / (1024**3):.2f} GB")
Related Python Questions
View All PythonQuestions →
Created by
Apurv Gujjar
DevOps & Cloud Engineer
Specialized in:DevOpsAWSGCPKubernetesTerraformDocker
View Portfolio