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

258 天前
 ljlljl0
这段 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)
441 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/968521

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX