import os def count_chars_in_folder(folder_path): total_chars = 0 for filename in os.listdir(folder_path): filepath = os.path.join(folder_path, filename) if os.path.isfile(filepath): with open(filepath, 'r') as file: content = file.read() total_chars += len(content) print(f"fichier {filepath} = { len(content)}") return total_chars folder_path = '.' # mettre le chemin absolu vers le dossier ici total_chars = count_chars_in_folder(folder_path) print(f"Le nombre total de caractères dans les fichiers du dossier {folder_path} est : {total_chars}")