test1.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import configparser
  2. from PikaStdLib import MemChecker
  3. config = configparser.ConfigParser()
  4. config_string = '[DEFAULT]\n\
  5. ServerAliveInterval = 45\n\
  6. Compression = yes\n\
  7. CompressionLevel = 9\n\
  8. ForwardX11 = yes\n\
  9. \n\
  10. [bitbucket.org]\n\
  11. User = hg\n\
  12. \n\
  13. [topsecret.server.com]\n\
  14. Port = 50022\n\
  15. ForwardX11 = no\n\
  16. content = http://sbkpda.hazz.hrss.gov.cn:9001/nontax_platforml/nontax/pay?Q=wj%2Bf'
  17. config.read_string(config_string)
  18. print('\n========== config_string ==========')
  19. print(config_string)
  20. print('\n===== config.sections() =====')
  21. print(config.sections())
  22. print('\n===== config.options("DEFAULT") =====')
  23. print(config.options('DEFAULT'))
  24. mem = MemChecker()
  25. config.set('bitbucket.org', 'User', 'hhdd123')
  26. print('\n========= config["bitbucket.org"] bitbucket.org ===========')
  27. print(config['bitbucket.org'])
  28. section = config['bitbucket.org']
  29. section['User'] = '3833qwe'
  30. print('\n========= config["bitbucket.org"] ===========')
  31. print(config['bitbucket.org'])
  32. print('\n========= config.items("DEFAULT") ===========')
  33. print(config.items('DEFAULT'))
  34. print('\n=============== all ================')
  35. print(config)
  36. print("mem used now: %0.2f kB" % mem.getNow())
  37. print("mem used max: %0.2f kB" % mem.getMax())