import os
def list_folders_in_directory(directory_path, output_file):
with open(output_file, ‘w’) as f:
for item in os.listdir(directory_path):
item_path = os.path.join(directory_path, item)
if os.path.isdir(item_path):
f.write(item + ‘\n’)
if __name__ == “__main__”:
target_directory = “D:\Document\LapTrinhWeb” # Thay đổi đường dẫn tới thư mục cần kiểm tra
output_filename = “output.txt”
list_folders_in_directory(target_directory, output_filename)
print(“List of folders saved to”, output_filename)