Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

edit json file python

import json

with open('data.json', 'r+') as f:
    data = json.load(f)
    data['id'] = 134 # <--- add `id` value.
    f.seek(0)        # <--- should reset file position to the beginning.
    json.dump(data, f, indent=4)
    f.truncate()     # remove remaining part
Comment

PREVIOUS NEXT
Code Example
Python :: tan for python 
Python :: python server http one line 
Python :: kivy fixed window 
Python :: covariance matrix python 
Python :: save pandas dataframe to parquet 
Python :: django get superuser password 
Python :: pip install chatterbot 
Python :: python check operating system 
Python :: pip version command 
Python :: seaborn create a correlation matrix 
Python :: apply format to pandas datetime column 
Python :: python selenium get style 
Python :: python prompt for input 
Python :: django integer field example 
Python :: import numpy Illegal instruction (core dumped) 
Python :: pandas convert date to string 
Python :: NotImplementedError: Please use HDF reader for matlab v7.3 files 
Python :: brownie normalize to wei 
Python :: List comprehension - list files with extension in a directory 
Python :: upload file in colab 
Python :: python extract every nth value from list 
Python :: random select algo 
Python :: python nltk tokenize 
Python :: how to get the angle of mouse from the center 
Python :: how to change button background color while clicked tkinter python 
Python :: how to get the current web page link in selenium pthon 
Python :: update link python is python 3 
Python :: Import "decouple" could not be resolved Pylance 
Python :: how to send audio with inline telebot 
Python :: adjust tick label size matplotlib 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =