使用Python搜索变量模式

使用Python搜索变量模式,python,html,regex,Python,Html,Regex,如何从下面的HTML代码中找到变量模式 <element aria-label="like this video along with 3,358,980 other people" >...<element> 。。。 我想从上面的行中找到数字。如果感兴趣的行始终是“一些文本**感兴趣的数字**更多文本”,那么您可以将字符串拆分为双星号** split_string = "this is the number **3,444,333** I need".split('

如何从下面的HTML代码中找到变量模式

<element aria-label="like this video along with 3,358,980 other people" >...<element>
。。。

我想从上面的行中找到数字。

如果感兴趣的行始终是“一些文本**感兴趣的数字**更多文本”,那么您可以将字符串拆分为双星号**

split_string = "this is the number **3,444,333** I need".split('**')
number_of_interest = split_string[1]

在这种情况下,我认为您需要一个简单的正则表达式。只需查找一串数字和逗号(可选):

>>> s='aria-label="like this video along with **3,358,980** other people"'
>>> print(re.search(r"([\d,]+)", s).group(0))
3,358,980

这严格适用于具有可选值的整数、非十进制小数
一千个分离器


\d+(?:,\d{3})*

html-code?????/我在上面找不到任何标记。@AvinashRaj:我猜,是从一些
输入元素中提取的。这已经被问了一千次了,我们从哪里可以看到您的一些努力?记住:这不是一个用来转储待办事项列表的站点。