我正在编写一个 python 脚本,该脚本从以前的终端窗口命令中获取输出并再次输入。这是代码
pathCmd = './adb shell pm path com.example.deliveryupdater'
pathData = os.popen(pathCmd,"r")
for line in pathData:
path = line
print line
if line.startswith("package:"):
apkPath = line[8:]
print apkPath
pullCmd = './adb pull ' + apkPath
pullData = os.popen(pullCmd,"r")
输出如下:/data/app/com.example.deliveryupdater-1.apk
' 不存在/data/app/com.example.deliveryupdater-1.apk
它说路径不存在。当我将路径硬编码为
pullCmd = './adb pull /data/app/com.example.deliveryupdater-1.apk'
pullData = os.popen(pullCmd,"r")
.apk 数据被拉取。
3886 KB/s (2565508 bytes in 0.644s)
有没有办法可以将字符串作为变量传递?我在这里做错什么了吗?请帮忙