I couldn't find an answer in the internet or stackoverflow but I have tried this method but it's not good one
from os import popen
output = popen("free -ht").read()
print(output[154:-90])
output: 2.4G
Is there any python library for this or at least a solution.