Python ConfigParser 模块重命名一个部分

标签 python configparser

如何重命名 ConfigParser 对象中的部分?

最佳答案

示例辅助函数 - 确实很傻,但它可能会节省一些人几分钟的工作......

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)

关于Python ConfigParser 模块重命名一个部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15069127/

相关文章:

Python 的winsound.Beep() 暂停问题

python - 从 Google App Engine 上的 Blob_Info 获取 key 时出错

python - 用户名/密码程序的打印语句不正确

python - 使用全局选项解析 rsyncd 配置文件时出现 ConfigParser.MissingSectionHeaderError

python - 在 Python ConfigParser 中按字母顺序导出

python - ConfigParser 与导入配置

python - 在目录中创建一个文件夹并将文件保存在新文件夹中

python - 在 Hadoop Streaming 中使用象鸟输入格式时出错

Python Json 配置 'Extended Interpolation'

python - 尝试使用 PyQt5 在两个类之间发送信号以更改 configparser 中的标签