I want to get the size of  3 files. I already completed this step. Then I
need to sum the 3 results I got. In order to do it I have the next code:

import os
file_list = []
folders = None
for root, folders, files in os.walk('C:\\'):
            file_list.extend(os.path.join(root,fi) for fi in files if
(fi.endswith.shp))
for row, filepath in enumerate(file_list, start=1):
            n = os.path.splitext(filepath)
            p = n[0]+'.prj'
            shx = n[0]+'.shx'
            s = os.path.getsize(filepath)

#Function to get size in humam readable terms:
            def sizeof_fmt(num):
                 for x in ['bytes','KB','MB','GB','TB']:
                      if num < 1024.0:
                           return "%3.1f%s" % (num, x)
                      num /= 1024.0

            kb = sizeof_fmt(s)
            shx1 = os.path.getsize(shx)
            kb2 = sizeof_fmt(shx1)

#Finally I want to sum the 3 terms:
total = kb+kb2+kb3
But the output I got is : 15.5KB108.0bytes169.0bytes

Does anyone have an idea how to fix it?
Thank you!!
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to