简体   繁体   English

Python中的标准配置文件名和扩展名是什么?

[英]What's the standard config file name and extension in Python?

I'm creating a config file to hold configuration/properties settings for my project that frequently change, such as file paths. 我正在创建一个配置文件来保存经常更改的项目的配置/属性设置,例如文件路径。 What's the standard name/extension for such a file? 这样一个文件的标准名称/扩展名是什么? (eg in Java I've used config.xml, in VB.NET I've used App.config...) (例如在Java中我使用了config.xml,在VB.NET中我使用过App.config ...)

First, consider using ConfigParser (configparser in 3.0, so the documentation says). 首先,考虑使用ConfigParser(3.0中的configparser,文档说明)。 That doesn't solve the naming problem, but it is a readable alternative to xml for most configuration needs. 这并不能解决命名问题,但对于大多数配置需求,它是xml的可读替代方案。

Whatever name you use, make all the parts meaningful. 无论您使用什么名称,都要使所有部分都有意义。 I would probably use something like appName.cfg, where appName identifies your application, or the part of the application the configuration is for. 我可能会使用类似appName.cfg的东西,其中appName标识您的应用程序,或者配置所针对的应用程序的一部分。

Ok, I've asked around where I work and researched a little, and this is what I've come up with as suggestions: 好的,我已经询问了我的工作地点并进行了一些研究,这就是我提出的建议:

  • settings.ini 的Settings.ini
  • applicationName.config applicationName.config
  • applicationName.cfg applicationName.cfg

If anyone has any other suggestions, feel free to add... 如果有人有任何其他建议,请随时添加...

The docs seem to use .cfg 文档似乎使用.cfg

On Windows, many people (such as mercurial) use .ini 在Windows上,许多人(例如mercurial)使用.ini

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM