有没有一种标准的方法来获取python中的用户配置目录 [英] Is there a standard way to get the user config directory in python

查看:58
本文介绍了有没有一种标准的方法来获取python中的用户配置目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 os.path.expanduser(〜)回家,但是是否有获取配置目录的标准方法?像大多数unices中的〜/ .config 一样,或者(最近?)Linux中的 $ XDG_CONFIG_HOME C:\Users\< user> \AppData\Local\Roaming 在Windows中)等

I can get the home with os.path.expanduser("~") but is there a standard way to get the config directory? Like ~/.config in most unices, or the value of $XDG_CONFIG_HOME in (recent?) Linux and C:\Users\<user>\AppData\Local\Roaming in Windows), etc

推荐答案

您可以利用python第三方库 appdirs 跨多个平台(Windows,Linux和Mac)为您完成所有繁重的工作

You can take advantage of python third party library appdirs which does all the heavy lifting for you across multiple platforms ( Windows, Linux & Mac )

这篇关于有没有一种标准的方法来获取python中的用户配置目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆