pip install prettytable
import glob
import subprocess
from prettytable import PrettyTable
# One-liner with pretty printing
test = lambda a, b: (lambda table: [table.add_row([file, subprocess.getoutput(f'du -h "{file}"')]) for file in glob.glob(f'{a}*.{b}') if file] and print(table))(
PrettyTable(field_names=["File", "Disk Usage"])
)
# Example usage
test('./', 'txt')
No hay comentarios:
Publicar un comentario