国产探花免费观看_亚洲丰满少妇自慰呻吟_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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安化县| 北海市| 井研县| 射洪县| 连云港市| 太保市| 通州市| 皮山县| 许昌市| 尚志市| 庄河市| 甘孜| 济阳县| 黄浦区| 孝义市| 女性| 桦甸市| 开阳县| 石泉县| 彩票| 洱源县| 扶风县| 廊坊市| 金山区| 固原市| 高台县| 奈曼旗| 新竹县| 扎囊县| 宜黄县| 修水县| 巴彦县| 华容县| 阳城县| 屯留县| 常山县| 合肥市| 宜兴市| 莱阳市| 通许县| 饶河县|