请帮助我获得我想要的输出

Please help me in getting the output I want

local = f"/home/server/Desktop/backupdestination/{year}/{month}/{date}/"
def a():
    size=0
    for root, dir_, files in os.walk(local):
      for f in dir_:
        fp = os.path.join(root, f)
        size += os.path.getsize(fp)
    print(f" DATE {date} SERVER 1 Size is {size} " )

这给了我这样的输出,(8192)这是两个文件夹的组合)

DATE 26 SERVER 1 Size is 8192

我希望输出是这样的(4096是文件大小)

DATE 26 SERVER 1 Size is [foldername:4096 ,foldername: 4096]

我试过这段代码:

import os

def a(local):
    sizes = []
    for root, dir_, files in os.walk(local):
        for f in dir_:
            fp = os.path.join(root, f)
            size = os.path.getsize(fp)
            sizes.append(f'{f}:{size}')

    print(f" DATE SERVER 1 Size is [{','.join(sizes)}] " )

a('.')

示例输出:

DATE SERVER 1 Size is [BG2:0,collatz:0,DragonTurtle:4096,Finance:0,FindBuild38:4096]