# coding:utf-8 import os # popen返回文件对象,同open操作一样 for i in [1,2,2] : f = os.popen(r"nvidia-smi", "r") l = f.read().split('\n') print('|===============================+======================+======================|') print(int(l[9].split('|')[2].split(' / ')[0][0:-3] )) print(int(l[13].split('|')[2].split(' / ')[0][0:-3])) print(int(l[17].split('|')[2].split(' / ')[0][0:-3])) print(int(l[21].split('|')[2].split(' / ')[0][0:-3])) print('|===============================+======================+======================|') f.close()
标签:显存,int,popen,查询,split,print,os From: https://www.cnblogs.com/yuchenking/p/16620580.html