com.kingsware.uiautomator.automator.Selector@15efac; boundsInParent: Rect(0, 0 - 729, 68); boundsInScreen: Rect(228, 471 - 957, 539); packageName: com.tencent.mm; className: android.view.View; text: 微信发送测试群; contentDescription: null; viewId: com.tencent.mm:id/hg4; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longClickable: false; enabled: true; password: false; scrollable: false; [ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN],请写一个正则表达式把boundsInScreen:Rect()里面的数据提取出来
时间: 2024-03-11 21:51:29 浏览: 183
Python库 | putio_automator-2.0.0.dev2-py3-none-any.whl
好的,这是一个提取矩形框坐标的正则表达式:`boundsInScreen:\s*Rect\((\d+),\s*(\d+)\s*s*(\d+),\s*(\d)`。使用时,可以先将文本中的换行符去掉,并将其中的矩形坐标数据提取出来。例如,在Python中可以这样使用:
```python
import re
text = "com.kingsware.uiautomator.automator.Selector@15efac; boundsInParent: Rect(0, 0 - 729, 68); boundsInScreen: Rect(228, 471 - 957, 539); packageName: com.tencent.mm; className: android.view.View; text: 微信发送测试群; contentDescription: null; viewId: com.tencent.mm:id/hg4; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longClickable: false; enabled: true; password: false; scrollable: false; [ACTION_SELECT, ACTION_CLEAR_SELECTION, ACTION_ACCESSIBILITY_FOCUS, ACTION_SHOW_ON_SCREEN]"
match = re.search(r'boundsInScreen:\s*Rect\((\d+),\s*(\d+)\s*-\s*(\d+),\s*(\d+)\)', text.replace('\n', ' '))
if match:
x1, y1, x2, y2 = match.groups()
print("矩形框坐标:({}, {})-({}, {})".format(x1, y1, x2, y2))
else:
print("未找到矩形框坐标")
```
输出结果为:`矩形框坐标:(228, 471)-(957, 539)`。
阅读全文