I have a JSON file: oracle.json
{"Oracle_installation": [{"ORACLE_HOSTNAME": "paulsusm.xxx.com"}]}
Now, I had to read the JSON file values in my test.py file:
import json
with open('D:\oracle.json') as f:
data = json.load(f)
hostname = data['Oracle_installation'][0]['ORACLE_HOSTNAME']
print(hostname)
In the JSON file, the key:value pair is: (ORACLE_HOSTNAME, paulsusm.xxx.com)
. I need to change the ORACLE_HOSTNAME
value in another file db.rsp
. My python code is supposed to search the "ORACLE_HOSTNAME"
word in db.rsp
file and change the value, which is stored in 'hostname'
variable in python. How can I do this in python?