ljlljl0
V2EX  ›  问与答

mac 上运行 py2app 打包的 Python 代码,部分功能失效

  •  
  •   ljlljl0 · Aug 26, 2023 · 1172 views
    This topic created in 1034 days ago, the information mentioned may be changed or developed.
    这段 Python 代码在 vscode 运行正常,一旦用 py2app 打包运行,点击就只能导出一个文件,还是空内容。
    很神奇,有大佬知道哪里原因吗

    #导出知识库功能
    def export_table_data():
    conn = sqlite3.connect('xx.db')
    cursor = conn.cursor()

    # 查询数据库中的内容
    cursor.execute("SELECT * FROM knowledge_base")
    knowledge_base_results = cursor.fetchall()

    conn.close()

    selected_directory = filedialog.askdirectory(title="选择保存目录")
    if selected_directory:
    output_directory = os.path.join(selected_directory, "知识库")
    os.makedirs(output_directory, exist_ok=True)

    for row in knowledge_base_results:
    title = row[1]
    content = row[2]

    filename = title + ".md"
    filepath = os.path.join(output_directory, filename)

    with open(filepath, "w") as f:
    f.write(content)
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   906 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 20:47 · PVG 04:47 · LAX 13:47 · JFK 16:47
    ♥ Do have faith in what you're doing.