subprocess模块执行shell命令
subprocess.run
获取当前系统下的一些基本信息
import subprocess
OS_res = subprocess.run('cat /etc/os-release|grep "VERSION="', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
os_version = OS_res.stdout.decode('utf-8')
REP_res = subprocess.run('cat /etc/apt/sources.list|grep ^deb', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
REP_info = REP_res.stdout.decode('utf-8')
print(os_version)
print(REP_info)