自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

用python(V1.0)如何匹配HTML標簽的實際操作

開發(fā) 后端
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標簽

 

  1. #coding:utf-8  
  2. import re  
  3. nStr = "<div>" 
  4. p = re.compile('</?\w+[^>]*>',re.I)  
  5. if p.match(nStr):  
  6. print "exists"   

輸出

 

  1. else:  
  2. print "not"  
  3.  

 

URL相關(guān)匹配EMAIL地址

 

  1. import re  
  2. nStr = "hkebao@126.com" 
  3. p = re.compile('^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$',re.S)  
  4. if p.match(nStr):  
  5. print "exists"  
  6. else:  
  7. print "not"  
  8.  

 

 

python(V1.0) 匹配URL

 

  1. import re  
  2. nStr = "http://localhost" 
  3. p = re.compile('^[a-zA-z]+://(\w+(-\w+)*)
    (\.(\w+(-\w+)*))*(\?\S*)?$',re.S)  
  4. if p.match(nStr):  
  5. print "exists"  
  6. else:  
  7. print "not"  

 

 

以上的文章就是對python(V1.0 匹配HTML標簽與匹配URL的實際相關(guān)應(yīng)用方案的介紹。

【編輯推薦】

  1. Python復制文件的實際操作方案與代碼詳解
  2. Python矩陣轉(zhuǎn)置中的二維數(shù)組的實際操作方案介紹
  3. Python socket編程在具體應(yīng)用中前兩個步驟的介紹
  4. Python Library中Condition的具體操作方案
  5. 在Python Library中Event具體實際操作方案

 

 

責任編輯:佚名 來源: 博客園
相關(guān)推薦

2010-03-15 16:54:11

Python字典

2009-08-26 16:37:04

ibmdwRational

2010-03-26 08:46:29

Python 2.5.

2010-03-12 15:29:19

Pythonexe

2010-03-10 19:00:20

Pythonnext函

2010-03-09 18:55:27

Python djan

2010-05-10 10:19:28

Oracle實戰(zhàn)RMA

2010-03-16 12:39:09

python for

2010-03-25 17:28:41

Python配置

2010-06-01 15:54:46

MySQL-pytho

2010-03-23 16:30:47

Python文件復制

2010-07-02 11:10:56

SQL Server

2010-03-31 16:11:00

Oracle啟動

2010-04-01 13:39:43

Oracle Name

2010-05-18 17:39:13

MySQL alter

2010-04-14 17:06:41

Oracle安裝路徑

2010-04-16 13:59:40

Oracle數(shù)據(jù)

2010-03-09 09:32:20

Python網(wǎng)頁爬蟲

2010-04-01 14:06:13

Oracle Name

2010-04-20 11:06:33

Oracle索引
點贊
收藏

51CTO技術(shù)棧公眾號