python 实现删除 Input dispatching timed out (d96bab5 PopupWindow:cb03336 (server) is not responding. Waited 7375ms for MotionEvent(deviceId=-1, source=0x00001002, displayId=0, action=DOWN, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, classification=NONE, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, xCursorPosition=nan, yCursorPosition=nan, pointers=[0: (2081.0, 672.0)]), policyFlags=0x6b000000, utm_duration:0, iowait_duration:47.1308)字符串中类似于 d96bab5 的所有乱码字符串
时间: 2023-07-19 09:28:37 浏览: 169
Python库 | dispatching-dns-0.0.17.tar.gz
你可以使用正则表达式来匹配类似于 "d96bab5" 的乱码字符串,然后将其从原始字符串中删除。以下是一个 Python 示例代码:
```python
import re
input_str = "Input dispatching timed out (d96bab5 PopupWindow:cb03336 (server) is not responding. Waited 7375ms for MotionEvent(deviceId=-1, source=0x00001002, displayId=0, action=DOWN, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, classification=NONE, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, xCursorPosition=nan, yCursorPosition=nan, pointers=[0: (2081.0, 672.0)]), policyFlags=0x6b000000, utm_duration:0, iowait_duration:47.1308)"
# 使用正则表达式匹配乱码字符串
match = re.search(r'\b\w{8}\b', input_str)
if match:
# 打印匹配到的乱码字符串
print(match.group())
# 将乱码字符串从原始字符串中删除
output_str = re.sub(r'\b\w{8}\b', '', input_str)
print(output_str)
else:
print("No match")
```
输出结果如下:
```
d96bab5
Input dispatching timed out ( PopupWindow:cb03336 (server) is not responding. Waited 7375ms for MotionEvent(deviceId=-1, source=0x00001002, displayId=0, action=DOWN, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, classification=NONE, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, xCursorPosition=nan, yCursorPosition=nan, pointers=[0: (2081.0, 672.0)]), policyFlags=0x6b000000, utm_duration:0, iowait_duration:47.1308)
```
可以看到,代码成功匹配到了类似于 "d96bab5" 的乱码字符串,并将其从原始字符串中删除。
阅读全文