auto.cfg
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes
其中:
-
DEFAULT为section
-
ServerAliveInterval/Compression
以上为option
import configparser
def read_config(cfg_file):
cfg = configparser.ConfigParser()
cfg.read(cfg_file)
return cfg
sys_cfg = read_config('../auto.cfg')
sys_cfg.get('DEFAULT','ServerAliveInterval')