When saving data, the format becomes this mode. There are many such data:
{"status": "0", "msg": "ok", "result": {"name": "Dew", "content": "<p>release name
When the autumn dew is heavy, go to the flowers and plants in the morning to collect it.</p><p>Smell
Sweet, flat and non-toxic.</p>Stop thirst. Baihua Dew: Can make the skin healthy. Cypress Leaf Dew, Calamus Dew: Wash your eyes every morning, can enhance vision.
Leek Leaf Dew: Treat vitiligo. Apply to the affected area every morning. </p>", "commentary": "", "translation": "", "appreciation": "", "interpretation": ""}}
{"status": "0", "msg ": "ok", "result": {"name": "明水", "content": "<p>
世名
is also called Fangzhushui. Fangzhu is one The name of the big clam. On a moonlit night, catch Fang Zhu and take the water stored in its shell. If it is clear and pure, it is Fang Zhu water.</p><p>
Smell Sweet, cold, non-toxic.</p><p>
Indications Used to wash eyes, it can remove fog and improve eyesight. Drinking this water also has a calming effect and can also relieve children's troubles. Hot.</p>", "commentary": "", "translation": ""}}
After type, the format is displayed as a string. I used the built-in function, but it still failed to convert it to the standard dictionary format, as follows:
from pprint import pprint import json import requests
with open('bencao_detail','r',encoding='utf8') as file: str_file = file.read()
The output results are as follows:str_file
'{"status": "0", "msg": "ok", "result": {"name": "Dew", "content": "<p> Name
When the autumn dew is heavy, go to the flowers and plants in the morning to collect it.</p><p>Smell
Sweet, flat, non-toxic.</p> ;<p>Indications
Used to decoct the medicine to moisten the lungs and kill insects, or mix the powder for treating scabies and worms into topical medicine, which can enhance the curative effect.
White Flower Dew : Stop thirst.
Baihua Dew: Can make the skin healthy.
Cypress Leaf Dew, Calamus Dew: Wash your eyes every morning, can enhance vision.
Leek Leaf Dew: Treat vitiligo. Apply to the affected area every morning .</p>", "commentary": "", "translation": "", "appreciation": "", "interpretation": ""}}n{"status": "0", "msg" : "ok", "result": {"name": "明水", "content": "<p>世名
is also called Fangzhushui. Fangzhu is a kind of The name of the big clam. On a moonlit night, catch Fang Zhu and take the water stored in its shell. If it is clear and pure, it is Fang Zhu water.</p><p> Smell
Sweet , cold, non-toxic.</p><p>Indications
Used to wash eyes, it can remove fog and improve eyesight. Drinking this water also has a calming effect and can also relieve irritability in children. .</p>", "commentary": "", "translation": ""}}n{"status": "0", "msg": "ok", "result": {"name": "Winter Frost", "content": "<p>release
How to get the frost: sweep it with chicken feathers, put it into a bottle, seal it and store it in a cool place. Even if it turns into liquid, Li</p><p>Smell
Sweet, cold, non-toxic.</p><p>Indications
Drinking winter frost can To relieve hangover fever, if you feel hot and flushed ears after drinking, drink it and it will disappear immediately. For typhoid fever and nasal congestion, drinking winter frost can also clear your nose. For prickly heat and redness and swelling under the armpits, apply winter frost and clam powder, which is effective. For malaria caused by cold and heat, you can treat autumn frost or winter frost for one and a half qian, along with hot wine, and it will also be effective. </p>", "commentary" : "", "translation": ""}}n
How can I make it a dictionary one by one?
In fact, eval is the simplest in this standard dictionary format.
You all know
import json
, why don’t you ask questions