Answers for "python replace list of ips from yaml file with new list"

0

python replace list of ips from yaml file with new list

import yaml

fname = "some.yaml"

stream = open(fname, 'r')
data = yaml.load(stream)

data['instances'][0]['host'] = '1.2.3.4'
data['instances'][0]['username'] = 'Username'
data['instances'][0]['password'] = 'Password'

with open(fname, 'w') as yaml_file:
    yaml_file.write( yaml.dump(data, default_flow_style=False))
Posted by: Guest on January-23-2021

Code answers related to "python replace list of ips from yaml file with new list"

Python Answers by Framework

Browse Popular Code Answers by Language