简体   繁体   中英

parsing a config.ini file in python

so I have a config.ini file which I have to parse and use in my python script, I basically need to run a loop to get the REPOS_TO_CHECK in my script, can anyone help out in how to parse the file and run it in a loop in my script to get the REPOS_TO_CHECK parameters. Thanks.

GITHUB_URL = 'https://api.github.com'
GITHUB_ACCESS_TOKEN = 'xxx'
REPOS_TO_CHECK = [
    ('org1', 'repo1'),
    ('org2', 'repo2'),]

Use the configparser library.

import configparser
config = configparser.ConfigParser()
config.read('config.ini')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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