python读取内存和空闲内存

2021/4/23 7:27:07

本文主要是介绍python读取内存和空闲内存,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

# This is a sample Python script.import psutildef get_mem_info():mem = psutil.virtual_memory()mem1 = str(mem.total / 1024 / 1024 / 1024)mem2 = str(mem.free / 1024 / 1024 / 1024)print("内存总数为:", mem1[0:3], "G")print("空闲内存总数:", mem2[0:3], "G")# Press Ctrl+F8 to toggle the breakpoint.# Press the green button in the gutter to run the script.if __name__ == '__main__':get_mem_info()# get_one_video("D:/11111.mp4")# get_mem_info()# print_hi('PyCharm')# See PyCharm help at https://www.jetbrains.com/help/pycharm/


这篇关于python读取内存和空闲内存的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程