Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

帮我写一段python代码实现:遍历当前文件夹,输出里面的.dll文件的名字,按行存储

  1. User

    帮我写一段python代码实现:遍历当前文件夹,输出里面的.dll文件的名字,按行存储

  2. Assistant

    import os

    folder_path = os.getcwd() # 获取当前文件夹路径 dll_files = []

    遍历当前文件夹

    for file_name in os.listdir(folder_path): if file_name.endswith(".dll"): dll_files.append(file_name)

    按行存储文件名

    with open("dll_files.txt", "w") as file: file.writelines("\n".join(dll_files))