📜  从字符串python代码示例中提取数字

📅  最后修改于: 2022-03-11 14:45:13.739000             🧑  作者: Mango

代码示例4
# Python program to extract digits from string

# take string
string = "kn4ow5pro8am2"

# print original string
print("The original string:", string)

# using join() + filter() + isdigit()
num = ''.join(filter(lambda i: i.isdigit(), string))

# print extract digits
print("Extract Digits:", num)