发布时间:2023-04-06 19:30
import re
str_ = "我11是个32字符串,我中4间有677数字88"
number = re.findall("\d+",str_) # 输出结果为列表
# 列表中的数字的数据类型是str
# ['11', '32', '4', '677', '88']
number = [int(x) for x in number] # 将str格式的数字转换成int
print(number)
# [11, 32, 4, 677, 88]