[Python] How to initialize ConfigParser with structured dict?

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I want to initialize configparser with structured dict like:

    from configparser import ConfigParser
    from sys import stdout

    structured_dict = dict(section1=dict(option1=1, option2=2, option3=3))
    config = ConfigParser(structured_dict)
    config.write(stdout)
    # my expected result:
    # [section1]
    # option1=1
    # option2=2
    # option3=3
    # ... but nothing to show

    Environment

    • Python 3.10

    Continue reading...

Compartilhe esta Página