用python(V1.0)如何匹配HTML標簽的實際操作
作者:佚名
python作為計算機語言中被廣泛應(yīng)用的腳本語言,已被大家了解。但是你對python(V1.0)的實際相關(guān)應(yīng)用是否了解呢?以下就是文章的具體介紹。
下的文章就是對python(V1.0)在實際相關(guān)應(yīng)用方案的具體應(yīng)用,如果你對python(V1.0)在匹配HTML標簽的具體應(yīng)用方案的具體介紹,如果你對其感興趣的話,你就可以點擊我們的文章。
匹配HTML標簽
- #coding:utf-8
- import re
- nStr = "<div>"
- p = re.compile('</?\w+[^>]*>',re.I)
- if p.match(nStr):
- print "exists"
輸出
- else:
- print "not"
URL相關(guān)匹配EMAIL地址
- import re
- nStr = "hkebao@126.com"
- p = re.compile('^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$',re.S)
- if p.match(nStr):
- print "exists"
- else:
- print "not"
python(V1.0) 匹配URL
- import re
- nStr = "http://localhost"
- p = re.compile('^[a-zA-z]+://(\w+(-\w+)*)
(\.(\w+(-\w+)*))*(\?\S*)?$',re.S)- if p.match(nStr):
- print "exists"
- else:
- print "not"
以上的文章就是對python(V1.0 匹配HTML標簽與匹配URL的實際相關(guān)應(yīng)用方案的介紹。
【編輯推薦】
- Python復制文件的實際操作方案與代碼詳解
- Python矩陣轉(zhuǎn)置中的二維數(shù)組的實際操作方案介紹
- Python socket編程在具體應(yīng)用中前兩個步驟的介紹
- Python Library中Condition的具體操作方案
- 在Python Library中Event具體實際操作方案
責任編輯:佚名
來源:
博客園