标签:col code igp ros imp com x11 key ons
1 import configparser 2 config = configparser.ConfigParser() 3 #写 4 config[‘bitbucket.org‘] = {} 5 config[‘bitbucket.org‘][‘User‘] = ‘hg‘ 6 config[‘topsecret.server.com‘] = {} 7 topsecret = config[‘topsecret.server.com‘] 8 topsecret[‘Host Port‘] = ‘5022‘ 9 topsecret[‘ForwardX11‘] = ‘no‘ 10 config[‘DEFAULT‘][‘ForwardX11‘] = ‘yes‘ 11 with open(‘example.ini‘,‘w‘) as f: 12 config.write(f) 13 config.read(‘example.ini‘) 14 #读,定义在DEFAULT里的东西会默认读出来 15 for key in config[‘bitbucket.org‘]: 16 print(key) 17 print(config.options(‘bitbucket.org‘)) 18 print(config.items(‘bitbucket.org‘)) 19 #增加 20 config.add_section(‘yuan‘) 21 config.set(‘bitbucket.org‘,‘k1‘,‘11111‘) 22 #删除 23 config.remove_section(‘topsecret.server.com‘) 24 config.remove_option(‘bitbucket.org‘,‘User‘) 25 config.write(open(‘example.ini‘,‘w‘))
标签:col code igp ros imp com x11 key ons
原文地址:https://www.cnblogs.com/josie930813/p/9835413.html