配置檔案的讀取與寫入

2021-09-02 16:25:42 字數 505 閱讀 2720

讀取配置檔案:

public static void main(string args) catch (exception e)

}

寫入配置檔案:

properties prop = new properties();

///儲存屬性到b.properties檔案

fileoutputstream ofile = new fileoutputstream("src/test/test.properties", false);//true表示把當前已有的配置重新在寫一遍,false則是只新增新寫入的

prop.setproperty("phone", "10086");//要寫入的配置

prop.store(ofile, "this is phone");//寫入並新增注釋

ofile.close();

讀取 寫入 配置檔案

引用 using system.runtime.interopservices using system.text dllimport kernel32 private static extern long writeprivateprofilestring string section,strin...

python讀取寫入配置檔案

初始化 cf configparser.configparser cf.read config config.ini 返回所有的分組 secs cf.sections print sections secs factory分組下所有key f cf.options factory print fac...

Python 配置檔案的讀取和寫入

安裝成功之後就能夠使用configparser了。from configparser import configparser class confighandle configparser def init self,filename super init self.read filename,en...