引入库
import configparser
配置文件读取
样例配置文件
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes
[bitbucket.org]
User = Atlan
[topsecret.server.com]
Port = 50022
ForwardX11 = no
config = configparser.ConfigParser()
config.read('example.ini')
print(config['bitbucket.org']['user'])
config相当于是一个字典,读出的所有值均为字符串,如果有需要,手动转换即可
浙公网安备 33010602011771号