Write and Read Dictionary To JSON file in Python | Python Tutorial

preview_player
Показать описание
Your donation will support me to continue to make more tutorial videos!

If you write programs in Python, more likely than not, at one point you will have to either write a dictionary to a JSON file or read a dictionary from a JSON file. Fortunately, reading and dumping JSON files are super easy in Python. In this tutorial I will show you how to write a dictionary to a JSON file and how to read a dictionary from a JSON file.

Python script

Visit my website
Рекомендации по теме
Комментарии
Автор

If you use "with open..." you dont have to close the file, it will close automatically at the end. Look at the documentation: -->>>>
""""It is good practice to use the "with" keyword when dealing with file objects. The advantage is that the file is properly closed after its suite finishes, even if an exception is raised at some point. Using with is also much shorter than writing equivalent try-finally blocks""""

mad_coder
Автор

thankyou so so so much JIE JENN
i was finding this method for so long but did not get it...u made it so easy...thankyou

malaikabatool
Автор

Crystal clear.
I hope this will solve my problem.

someshvemula
Автор

I love you my brother. you solved my problem 👍👍👍

susovandas
Автор

if you have 2 strings is there a way to put a one below the other in the json

wolfcub
Автор

I got the error down below when I used json.load method
"JSONDecodeError: Expecting value: line 1 column 1 (char 0)"

and I got the error down below when I used json.loads method
"TypeError: the JSON object must be str, bytes or bytearray, not TextIOWrapper"

Can anybody help me ?

Hyper
Автор

File is overwritten whenever i add new elements

rohanyemul
Автор

video is good but not very clear in terms of the codes you need to adjust the screen

anthonymutonga