Q:

python read config file "configparser"

working on read external config file in python(3.7) using module "configparser" 
Sample configuration file "config.ini"
[ABC]
ch0 = "C:/Users/utility/ABC-ch0.txt"
ch1 = "C:/Users/utility/ABC-ch1.txt"

[settings]
script = "C:/Users/OneDrive/utility/xxxx.exe"
settings = "C:/Users/OneDrive/xxxxxxConfig.xml"

here is my sample code i tryed
import configparser
config = configparser. ConfigParser()

config.read('config.ini')
ch0 = config.get('ABC','ch0')
print(ch0)

here is the error code i am getting , not sure where i am going wrong
NoSectionError: No section: 'ABC'

any help is much appreciated.. thanks in advance

A:

Your code is absolutely fine. 
This line:
config.read('config.ini')

tries to read the file from the same directory as the .py file you're running.  So you have 3 options:

move the config.ini file to be next to the .py file
use a correct relative path when reading the file
use an absolutely path when reading the file

