import os
import time
def screen(path):
cmd0 = 'adb remount'
os.popen(cmd0)
time.sleep(1)
cmd1 = 'adb shell screencap -p /sdcard/1.png'
os.popen(cmd1)
time.sleep(7)
cmd2 = "adb pull /sdcard/1.png {}".format(path)
os.popen(cmd2)
time.sleep(2)
cmd3 = 'adb shell rm /sdcard/1.png'
os.popen(cmd3)
time.sleep(1)
print("截图完成")
if __name__=='__main__':
screen("E:\import//test.png")
运行结果:
D:\Python3.8.6\python.exe D:/PythonWorkSpace/chenbang/test_9.py
5409 KB/s (1110383 bytes in 0.200s)
截图完成
Process finished with exit code 0