# coding=utf-8
"""
作者:gaojs
功能:
新增功能:
日期:2022/5/15 21:56
"""
import configparser
def create_config():
"""
创建配置文件
:return:
"""
config = configparser.ConfigParser()
config['DEFAULT'] = {'serveraliveinterval': '4',
'compression': 'yes',
'compressionlevel': '9'}
config['username'] = {}
config['username']['admin'] = 'gaojianshuai'
config['username']['array'] = 'gaojs'
config['topsecrect'] = {}
topsecrect = config['topsecrect']
topsecrect['port'] = '22'
with open('configuration.ini', 'a') as configfile:
config.write(configfile)
def read_config():
"""
读取配置文件
:return:
"""
config = configparser.ConfigParser()
config.read('configuration.ini')
for key in config['DEFAULT']:
print(key)
config.get('DEFAULT', 'compression')