文件內容:mysql
[docker]
un = 192.12.32.12
foe = 10.1.2.3
[mysql]
mydb = 172.2.3.1sql
腳本內容:docker
getJson(file): ConfigParser config cf = config.ConfigParser() cf.read(file) sdf = cf.sections() dic = {} x sdf: status = k,v cf.items(x): status == : dic[x]={k:v} status += : dic[x][k]=v status = dic __name__==: getJson()