137 of 151 menu

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 stat of module os,
    which returns the status of the path
  • method path.getsize of module os,
    which returns the size of the path in bytes
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline