python:放置计算机用户可以编辑的应用程序数据的位置

发布于 2024-09-01 17:07:09 字数 303 浏览 1 评论 0原文

我正在开发一个非常简单的 python 包供我们内部使用,并希望将其打包为 .egg 文件,当安装/使用它时,我希望它访问放置在计算机上适当位置的文本文件。

那么在 python 中放置应用程序数据的最佳位置在哪里呢? (这意味着由用户编辑)如何让我的 python 包自动安装默认文件?

注意:我知道Windows应用程序数据目录,但想避免它,因为它是不可移植的对于用户访问和我的应用程序访问来说都有点麻烦。

I'm working on a really simple python package for our internal use, and want to package it as a .egg file, and when it's installed/used I want it to access a text file that is placed in an appropriate place on the computer.

So where is the best place to put application data in python? (that is meant to be edited by users) How do I get my python package to automatically install a default file there?

note: I know about the Windows application data directory, but would like to avoid it, as it's nonportable and kind of cumbersome both for users to access and for my application to access.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素年丶 2024-09-08 17:07:09

每个操作系统都有自己的目录,其中应存在应用程序数据。似乎没有一种方法能够以独立于平台的方式提供此路径。您可以编写自己的函数来通过检查 os.name 来完成此操作,然后根据结果返回适当的值。

Each OS will have it's own directory where application data is expected to exist. There does not appear to be a method that provides this path in a platform-independent manner. You can write your own function to do this for you by checking os.name and then returning the appropriate value depending on the result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文