如何使用纯Python adb device.shell替换字符串?



我正在使用pure-python-adb

device.shell('input touchscreen tap 240 856')

以上内容正常运行。

之类的
SomeStr = "'" "input touchscreen tap " + str(476) + " " + str(421) + "'"
device.shell(SomeStr) 

根本不起作用。如果我打印SomeStr,它的读数为'input触摸屏点击476 421'

为什么我不能用字符串代替书面文本?不知道为什么这不起作用…如有任何帮助,不胜感激。

我已经尝试使用字符串。还有别的办法吗?

在您的"工作"中,单引号不会传递给adb。命令。不清楚你为什么要添加它们

你考虑过使用f字符串吗?您不需要单独的字符串变量,只需要坐标。

x = 240
y = 856
device.shell(f'input touchscreen tap {x} {y}')

最新更新