Frage

How can you rename a section in a ConfigParser object?

War es hilfreich?

Lösung 2

As far as I can tell, you need to

Andere Tipps

example helper function - silly really but it might save someone a few minutes work...

def rename_section(cp, section_from, section_to):
    items = cp.items(section_from)
    cp.add_section(section_to)
    for item in items:
        cp.set(section_to, item[0], item[1])
    cp.remove_section(section_from)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top