如何使用python更新.config文件?

如何使用python更新.config文件?,python,python-3.x,file-io,config,configuration-files,Python,Python 3.x,File Io,Config,Configuration Files,我有一个.config文件,其结构如下: model { ssd { num_classes: 4 box_coder { faster_rcnn_box_coder { y_scale: 10.0 x_scale: 10.0 height_scale: 5.0 width_scale: 5.0 } } 我需要更新变量num_类。怎样才能做到呢?提前谢谢

我有一个.config文件,其结构如下:

model {
  ssd {
   num_classes: 4
   box_coder {
   faster_rcnn_box_coder {
       y_scale: 10.0
       x_scale: 10.0
       height_scale: 5.0
       width_scale: 5.0
  }
}
我需要更新变量num_类。怎样才能做到呢?提前谢谢