Differences between JSON. Load() and JSON. Loads() in Python
Mr. li 2021-06-04 10:43:55

One 、 The illustration

json.loads(): Analyze an effective JSON String and convert it to Python Dictionaries
json.load(): Read from a file JSON Data of type , And then convert to Python Dictionaries

Two 、json.loads() usage


import json

data = {
    "name""Satyam kumar",
    "skills": [
        "Raspberry pi",
        "Machine Learning",
        "Web Development"
    "projects": [
        "Python Data Mining",
        "Python Data Science"
with open("data_file.json""w") as write:
    json.dump(data, write)

with open("data_file.json""r") as read_content:

Python and Json Mapping of data types

JSON Python
object dict
array list
string str
number int
true TRUE
false FALSE
null None

3、 ... and 、json.load() usage


import json

# JSON string:
# Multi-line string
data = """{ 
Name": "Jennifer Smith", 
Contact Number": 7867567898, 
Email": "jen123@gmail.com", 
Hobbies":["Reading", "Sketching", "Horse Riding"] 

# parse data:
res = json.loads(data)

# the result is a Python dictionary:

Four 、 At the end

Mr. li (Lemon), Senior operation and maintenance engineer ( Claim to be ),SRE Experts ( The goal is ), The dream is 35 I bought a Porsche when I was 20 years old . Like to delve into the underlying technology , Think that the bottom foundation is the king . All new technologies are inseparable from the operating system (CPU、 Memory 、 disk )、 Network, etc . Insist on input and output , Record your own learning , Keep moving forward in the ordinary , One day I will meet a different self . official account : Yunweiwang (ID:Leeeee_Li).

Please bring the original link to reprint ,thank
Similar articles