python正则替换非数字字符源码演示
更新:HHH   时间:2023-1-7


把内容过程中比较重要的一些内容段备份一次,下面内容段是关于python正则替换非数字字符演示的内容,应该对码农们有用途。

#!/usr/bin/python
import re

phone = "2004-959-559 # This is Phone Number"

# Delete Python-style comments
print "Phone Num : ", num

# Remove anything other than digits
num = re.sub(r'D', "", phone)    
print "Phone Num : ", num

执行结果如下

Phone Num :  2004-959-559
Phone Num :  2004959559
返回编程语言教程...