title: Why does Python find different file sizes to Windows?
body: <p>I'm creating a basic GUI as a college project. It scans a user selected hard drive from their PC and gives them information about it such as the number of files on it etc... </p>
  
  <p>There's a part of my scanning function that, for each file on the drive, takes the size of said file in bytes, and adds it to a running total. At the end of this, after comparing the number to the Windows total, I always find that my Python script finds less data than Windows says is on the drive. </p>
  
  <p>Below is the code...</p>
  
  <pre><code>import os
  
  overall_space_used = 0
  
  def Scan (drive):
      global overall_space_used
  
      for path, subdirs, files in os.walk (r"" + drive + "\\"):
          for file in files:
              overall_space_used = overall_space_used + os.path.getsize(os.path.join(path,file))
      print (overall_space_used)
  </code></pre>
  
  <p>When this is executed on one my HDDs, Python says there is 23,328,445,304 bytes of data in total (21.7 GB). However, when I go into the drive in Windows, it says that there is 23,536,922,624 bytes of data (21.9 GB). Why is there this difference? </p>
  
  <p>I calculated it by hand, and using the same formula that Windows used to convert from bytes to gibibytes (<code>gibibytes = bytes / 1024**3</code>), I still arrived .2 GB short. Why is Python finding less data? </p>