zoukankan      html  css  js  c++  java
  • python学习杂记--读取安卓设备sdcard中的文件列表

    在读取安卓手机sdcard中的文件列表时

    有几点需要注意的

    1.首先进入手机的sdcard文件列表(为了便于操作,生成了一个名为streamlist.txt的文件来存放文件名)

    1 file_path = "sdcard/itemfile"
    2 file_stream_path = []
    3 os.system("adb shell ls %s >>streamlist.txt 2>&1" % file_path)
    4 with open("streamlist.txt", 'r+') as sl:
    5     for line in sl:
    6         file_stream_path.append(
    7             str("/" + file_path + "/" + line).replace("
    ", ""))

    这里注意的是,目标文件的表达方式是“sdcard/itemfile”,而不是“/sdcard/itemfile”

    2.如果要通过cmd在指定的文件中写入输出信息,有两种方法os.system和os.popen

    os.system的形式如下

    1 os.system("adb shell input keyevent %s >>output.txt 2>&1"%i)
    2 或者
    3 os.system("echo -------------------------- >>output.txt 2>&1")

    os.system的结果不能输出到控制台,输出的只能是指令的运行结果(0,1,2,0表示成功)只能 运行 or 写入其他文件中

    os.popen的形式如下

  • 相关阅读:
    noip模拟70
    noip模拟测试62
    noip模拟66
    noip模拟67
    noip模拟64
    QATF自动化测试框架
    自动化领域谁主沉浮
    TestComplete9.2增强支持 Embarcadero RAD Studio XE3、Ext JS
    QTP对SAP的支持
    如何将makefile构建的工程导入C++test?
  • 原文地址:https://www.cnblogs.com/RuiRuia/p/14306764.html
Copyright © 2011-2022 走看看