python正则替换非数字字符源码演示
把内容过程中比较重要的一些内容段备份一次,下面内容段是关于python正则替换非数字字符演示的内容,应该对码农们有用途。
#!/usr/bin/pythonimport rephone = "2004-959-559 # This is Phone Number"# Delete Python-style commentsprint "Phone Num : ", num# Remove anything other than digitsnum = re.sub(r'D', "", phone) print "Phone Num : ", num执行结果如下Phone Num : 2004-959-559Phone Num : 2004959559
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。