我想从数组等级中仅提取数字
我无法仅提取尝试查找所有内容,包含内容等的数字。
rank[0]
<td class="blob-num js-line-number" data-line-number="100" id="L100"></td>]
len(rank)
100
>>> import re
>>> [int(s) for s in re.findall(r'\b\d+\b', rank[0])]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-256-5566677d4eea> in <module>
1 import re
----> 2 [int(s) for s in re.findall(r'\b\d+\b', rank[0])]
~/anaconda3/lib/python3.7/re.py in findall(pattern, string, flags)
221
222 Empty matches are included in the result."""
--> 223 return _compile(pattern, flags).findall(string)
224
225 def finditer(pattern, string, flags=0):
TypeError: expected string or bytes-like object