May-14-2019, 11:14 AM
Hello,
im using python3 on ubuntu 18 machine
i am new to python
i have this script :
i want to make an order here because im going to add
so the qustions are :
if i want to make an order in the response like this :
How can i keep the keys so it will look like this :
thanks
im using python3 on ubuntu 18 machine
i am new to python
i have this script :
import json import psutil d = {} mem = psutil.virtual_memory() dmem = mem._asdict() print(json.dumps(dmem))and i get this result :
Quote:["total": 4416118784, "available": 3831390208, "percent": 13.2]]and so on..
i want to make an order here because im going to add
Quote:psutil.swap_memory()
psutil.cpu_times()
psutil.cpu_percent(interval=1, percpu=True)
so the qustions are :
if i want to make an order in the response like this :
result = { 'RAM' : mem } print(json.dumps(result))i get the results without the keys :
Quote:["RAM": [4416118784, 3831066624, 13]
How can i keep the keys so it will look like this :
Quote:["RAM": [total : 4416118784, available : 3831066624, precent : 13]
thanks