【问题标题】:Unable to update .config file in python?无法在 python 中更新 .config 文件?
【发布时间】:2022-07-19 05:11:03
【问题描述】:

我有以下现有的 .config 文件,它是 jenkins 的一部分

test.config

1.1G input/path output/path

我看到了许多使用 configparser 直接更新 config.ini 文件的示例。

但是当我使用 configparser 读取这个 test.config 时,它会返回以下错误

config.read(test.config)

遇到错误

configparsor.MissingSectionHeaderError

我实际上需要如下更新我的 test.config 文件

#input 
table_details={'source_path1':'desti_path1',
                'source_path2':'desti_path2'}

#expected output in test.config

1.1G source_path1 desti_path1
1.1G source_path2 desti_path2

有什么解决办法吗?

【问题讨论】:

    标签: python-3.x configparser


    【解决方案1】:

    您是否在 python 中使用“configparser”库?如果是这样,设置文件应该是 *.ini 文件,而不是 *.config。让我知道这是否解决了问题。

    【讨论】:

      猜你喜欢
      • 2022-07-18
      • 1970-01-01
      • 1970-01-01
      • 2014-03-05
      • 2014-03-21
      • 2019-12-25
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      相关资源
      最近更新 更多