配置文件模块
# import configparser # # config = configparser.ConfigParser() # # # # config["DEFAULT"] = {'ServerAliveInterval': '45', # # 'Compression': 'yes', # # 'CompressionLevel': '9'} # # # # config['bitbucket.org'] = {'User':'hg'} # # # # config['topsecret.server.com'] = {} # # topsecret = config['topsecret.server.com'] # # topsecret['Host Port'] = '50022' # mutates the parser # # topsecret['ForwardX11'] = 'no' # same here # # config['DEFAULT']['ForwardX11'] = 'yes' # # # # # # # # with open('example.ini', 'w') as configfile: # # config.write(configfile) # # # print(config.sections()) # # config.read('example.ini') # # print(config.sections()) # # print(config.defaults()) # # # # print(config['bitbucket.org']['User']) # # # for key in config['bitbucket.org']: # # print(key) # # config.remove_section('topsecret.server.com') # print(config.has_section('topsecret.server.com')) # # config.remove_option('bitbucket.org','user') # # # config.set('bitbucket.org','user','alex') # # # config.write(open('example.ini', "w"))
人生短短数十载,经不起几次重头再来