思路
Python 拉取手机应用的内存占用的信息到本地,思路:
1、拉取手机应用内存占用的信息到本地
2、用关键字匹配你要查询的应用
3、并将物理内存、虚拟内存等信息存到csv中
代码实现
开始:
先简单封装个执行adb命令的方法
def execute_hdc_std_cmd(command):
s = subprocess.Popen(f'adb shell {
command}',
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
ex_info, ex_err = s.communicate()
s.wait()
s.kill()
return ex_info.decode('utf8'), ex_err.decode('utf8')
封装个执行命令行的方法
def execute_cmd(command: str):
s = subprocess.Popen(command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
ex_info, ex_err