pip install pyyaml python import yaml with open('config.yaml', 'r') as file: config = yaml.load(file, Loader=yaml.FullLoader) python host = config['database']['host'] port = config['database']['port'] username = config['database']['username'] password = config['database']['password'] python config['database']['username'] = 'new_username' with open('config.yaml', 'w') as file: yaml.dump(config, file) python import yaml with open('config.yaml', 'r') as file: config = yaml.load(file, Loader=yaml.FullLoader) host = config['database']['host'] port = config['database']['port'] username = config['database']['username'] password = config['database']['password'] config['database']['username'] = 'new_username' with open('config.yaml', 'w') as file: yaml.dump(config, file)


上一篇:
下一篇:
切换中文