V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ljlljl0
V2EX  ›  问与答

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

  •  
  •   ljlljl0 · 245 天前 · 430 次点击
    这是一个创建于 245 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这段 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)
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2967 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:02 · PVG 22:02 · LAX 07:02 · JFK 10:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.