Your best bet for a cross-platform solution is to use the psutil package (available on PyPI).
from psutil import virtual_memory
mem = virtual_memory()
mem.total # total physical memory available
Documentation for virtual_memory
is here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…