[Python] python读取ini配置文件 →→→→→进入此内容的聊天室

来自 , 2019-09-27, 写在 Python, 查看 133 次.
URL http://www.code666.cn/view/e1054bf2
  1.  
  2. #!/usr/bin/python
  3. # -*- coding: iso-8859-1 -*-
  4. import ConfigParser
  5.  
  6. # Open a configuration file
  7. config = ConfigParser.SafeConfigParser()
  8. config.read("config.ini")
  9.  
  10. # Read the whole configuration file
  11. for section in config.sections():
  12.     print "In section %s" % section
  13.     for (key, value) in config.items(section):
  14.         print "  Key %s has value %s" % (key, value)
  15. #//python/1883

回复 "python读取ini配置文件"

这儿你可以回复上面这条便签

captcha