资 源 简 介
The confparse python module can process simple properties files but also files with sections. It gives convenient access to the values, or gives features like variable evaluation or default values.
Configuration files can not only be read but also updated with one-liners, while keeping layout and comments intact. Options can be added, deleted, and uncommented. Confparse is extensible and can map new format without too much work.
I am circulating this alpha version to developers in the field in hopes that they can help removing the most egregious errors before too many other people see it (*).
Read a value from a file
Let"s say your file is one of the numerous "key=value" file such as a java properties file , a network interface file, etc.
from confparse import propertieshttp_port = properties( "/etc/my-app/config.conf" ).get( "HttpPort" )sip_port = properties( "/opt/sipserver/conf.txt" ).get( "SipPort", 5060 )
When you g