引入庫
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相當於是一個字典,讀出的所有值均爲字符串,如果有需要,手動轉換即可