micropython findall
时间: 2023-09-12 07:12:39 浏览: 190
python 如何使用find和find_all爬虫、找文本的实现
5星 · 资源好评率100%
The `findall` method in MicroPython is a regular expression function that searches for all occurrences of a pattern in a given string and returns a list of all matches found.
Here's an example of using `findall` in MicroPython:
```python
import re
string = "The quick brown fox jumps over the lazy dog"
pattern = r"\w{4}"
matches = re.findall(pattern, string)
print(matches)
```
Output:
```
['quick', 'brown', 'jumps', 'over', 'lazy']
```
In this example, the `findall` method searches for all occurrences of a pattern consisting of four consecutive word characters (`\w{4}`) in the given string. The method returns a list of all matches found, which are then printed to the console.
阅读全文