开发者

Where is a good place/way to store Windows config files for Python scripts?

开发者 https://www.devze.com 2022-12-31 01:19 出处:网络
I have a script/program I am working on that requires a configuration file (I am using ConfigParser).On linux, I will default to store these variables in ~/.myscript using the os.getenv(\'HOME\') func

I have a script/program I am working on that requires a configuration file (I am using ConfigParser). On linux, I will default to store these variables in ~/.myscript using the os.getenv('HOME') function.

With Windows, I know I can use os.getenv('USERPROFILE') to find the User's "home" directory, however, is it a good idea to save a hidden file that way (ie, with the name .myscript)?

I don't use Windows, obv开发者_如何学Ciously, but wanted to be smart about it for those who do.

Is there a standard place/way to store these config variables on Windows?


os.environ['AppData']

It's usual to create a folder inside with your organisation name and put any files inside that. There's no need to ‘hide’ the files, and . at the start of a filename isn't valid in Windows.

Or put the settings in the registry.

0

精彩评论

暂无评论...
验证码 换一张
取 消