📜  python 仅字符串中的数字 - Python 代码示例

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

代码示例1
string = "abc123"
# Method 1
''.join(char for char in string if char.isdigit())

#Method 2
import re
re.sub("[^0-9]", "", string)