国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python讀寫 ini配置文件方法實例分析

2019-11-02 14:20:25
字體:
來源:轉載
供稿:網友

   本文實例講述了python讀寫ini配置文件方法。分享給大家供大家參考。具體實現方法如下:

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 import ConfigParser import os class ReadWriteConfFile: currentDir=os.path.dirname(__file__) filepath=currentDir+os.path.sep+"inetMsgConfigure.ini" @staticmethod def getConfigParser(): cf=ConfigParser.ConfigParser() cf.read(ReadWriteConfFile.filepath) return cf @staticmethod def writeConfigParser(cf): f=open(ReadWriteConfFile.filepath,"w"); cf.write(f) f.close(); @staticmethod def getSectionValue(section,key): cf=ReadWriteConfFile.getConfigParser() return cf.get(section, key) @staticmethod def addSection(section): cf=ReadWriteConfFile.getConfigParser() allSections=cf.sections() if section in allSections: return else: cf.add_section(section) ReadWriteConfFile.writeConfigParser(cf) @staticmethod def setSectionValue(section,key,value): cf=ReadWriteConfFile.getConfigParser() cf.set(section, key, value) ReadWriteConfFile.writeConfigParser(cf) if __name__ == '__main__': ReadWriteConfFile
  希望本文所述對大家的Python程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌江| 大丰市| 鄂伦春自治旗| 昭通市| 西丰县| 高要市| 怀安县| 饶阳县| 黄石市| 澄江县| 溧阳市| 沾益县| 和顺县| 读书| 康保县| 得荣县| 广南县| 林芝县| 贵港市| 齐齐哈尔市| 济宁市| 灵宝市| 伊通| 九台市| 汶上县| 建始县| 凤山市| 鞍山市| 长岭县| 乐平市| 乐业县| 南陵县| 广丰县| 山东省| 壶关县| 山丹县| 苏尼特左旗| 疏勒县| 当涂县| 河西区| 四平市|