Domanda

How can you rename a section in a ConfigParser object?

È stato utile?

Soluzione 2

As far as I can tell, you need to

Altri suggerimenti

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top