Differences between revisions 2 and 3
Revision 2 as of 2007-11-16 17:38:47
Size: 167
Editor: host
Comment:
Revision 3 as of 2007-11-16 17:46:32
Size: 591
Editor: host
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
These are some examples on using ConfigParser... These are some examples on using ConfigParser, assuming the following INI file...
Line 3: Line 3:
{{{#!python
import ConfigParser
import sys
ConfigFileName="c:\\tomorrow.ini"
{{{
[SectionOne]
Status: Single
Name: Derek
Value: Yes
Age: 29
Single: True

[SectionTwo]
FavoriteColor=Green
[SectionThree]
FamilyName: Johnson

[Others]
Route: 66
}}}

{{{
>>> from ConfigParser import ConfigParser
>>> Config = ConfigParser()
>>> Config
<ConfigParser.ConfigParser instance at 0x00BA9B20>
>>> Config.read("c:\\tomorrow.ini")
['c:\\tomorrow.ini']
>>> Config.sections()
['Others', 'SectionThree', 'SectionOne', 'SectionTwo']
>>>

These are some examples on using ConfigParser, assuming the following INI file...

[SectionOne]
Status: Single
Name: Derek
Value: Yes
Age: 29
Single: True

[SectionTwo]
FavoriteColor=Green
[SectionThree]
FamilyName: Johnson

[Others]
Route: 66

>>> from ConfigParser import ConfigParser
>>> Config = ConfigParser()
>>> Config
<ConfigParser.ConfigParser instance at 0x00BA9B20>
>>> Config.read("c:\\tomorrow.ini")
['c:\\tomorrow.ini']
>>> Config.sections()
['Others', 'SectionThree', 'SectionOne', 'SectionTwo']
>>> 


CategoryDocumentation

ConfigParserExamples (last edited 2016-04-11 04:17:05 by bignose)

Unable to edit the page? See the FrontPage for instructions.