国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python操作toml文件的示例代碼

瀏覽:72日期:2022-07-04 09:19:23

# -*- coding: utf-8 -*-# @Time : 2019-11-18 09:31# @Author : cxa# @File : toml_demo.py# @Software: PyCharmimport tomlimport osBASE_DIR = os.path.dirname(os.path.abspath(__file__))class FileOperation: def __init__(self): self.dic = dict() self.toml_file_path = os.path.join(BASE_DIR, 'config.toml') def __add__(self, other): self.dic.update(self.other) return self.dic def write(self): mysql_dic = {'user': 'root', 'password': 'Aa1234'} mysql2_dic = {'user1': 'root', 'password2': 'Aa1234'} mysql_dic.update(mysql2_dic) with open(self.toml_file_path, 'w', encoding='utf-8') as fs: toml.dump(mysql_dic, fs) def read(self): with open(self.toml_file_path, 'r', encoding='utf-8') as fs: t_data = toml.load(fs) return t_dataif __name__ == ’__main__’: f = FileOperation() data = f.read() print(data)

以上就是python操作toml文件的示例代碼的詳細內容,更多關于python操作toml文件的資料請關注好吧啦網其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 汪清县| 安吉县| 乐陵市| 昭苏县| 牙克石市| 大渡口区| 霸州市| 三门县| 德化县| 新晃| 涞水县| 太保市| 林西县| 乌拉特中旗| 综艺| 泌阳县| 白银市| 垣曲县| 改则县| 晋城| 溧水县| 綦江县| 浦东新区| 和龙市| 娄烦县| 远安县| 克山县| 漳浦县| 揭西县| 云霄县| 伊川县| 通山县| 西充县| 宜都市| 邵阳县| 灵石县| 德昌县| 大连市| 湘阴县| 五大连池市| 盐亭县|