把内容过程中比较重要的一些内容段备份一次,下面内容段是关于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
来源:51CTO
作者:Cool_Manone
链接:https://blog.51cto.com/14101311/2390223