Python 3 latest code crumbs
Encoding JSON with json.dumps
Dec 7, 2021 by erik
Encoding JSON data with Python's json.dumps
is just as easy as decoding. Use json.dumps
(short for ‘dump to string') to convert a Python object consisting of dictionaries, lists, and other native types into a string. To learn more about JSON...
Read JSON with json.loads
Dec 7, 2021 by erik
Parsing a string of JSON data, also called decoding JSON, is as simple as using json.loads(…)
. Loads is short for load string. It converts: - objects to dictionaries - arrays to lists, - booleans, integers, floats, and strings are recognized...
Python append to text file
Dec 3, 2021 by erik
This is how you append data to a text file. 1. First, we open the file and write a couple of lines using the write file mode 'w'. 2. Next, we open it again to append some more lines using...
Python Playground
Nov 30, 2021 by erik
This is a simple Python online interpreter, where you can enter Python code, execute it, and view the results....
Read a file with open and close
Nov 30, 2021 by erik
The traditional way of opening a file in Python. I strongly recommend using the with
statement instead....