新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python正則表達(dá)式怎樣進(jìn)行Java中的使用
Python正則表達(dá)式在使用的時候需要注意很多問題,相關(guān)的Python正則表達(dá)式問題如只有不斷的學(xué)習(xí)才能更好的進(jìn)行解決。下面我們就看看如何才能更好的學(xué)習(xí)。希望大家有所收獲。

創(chuàng)新互聯(lián)主打移動網(wǎng)站、網(wǎng)站設(shè)計制作、網(wǎng)站制作、網(wǎng)站改版、網(wǎng)絡(luò)推廣、網(wǎng)站維護(hù)、空間域名、等互聯(lián)網(wǎng)信息服務(wù),為各行業(yè)提供服務(wù)。在技術(shù)實(shí)力的保障下,我們?yōu)榭蛻舫兄Z穩(wěn)定,放心的服務(wù),根據(jù)網(wǎng)站的內(nèi)容與功能再決定采用什么樣的設(shè)計。最后,要實(shí)現(xiàn)符合網(wǎng)站需求的內(nèi)容、功能與設(shè)計,我們還會規(guī)劃穩(wěn)定安全的技術(shù)方案做保障。
Java代碼
- #encoding=utf-8
- '''
- python learn regular express
- url : http://docs.python.org/library/re.html
- parse html url : http://www.boddie.org.uk/python/HTML.html
- author : liuzheng
- '''
- import re
- import urllib
- #分析javaeye blog 頻道
- class ParseHTML:
- '''
- parse html for infomation
- parse javeeye page
- '''
- def __init__(self,url):
- self.url = url
- pass
- #analyses html
- def parse(self):
- sock = urllib.urlopen(self.url)
- html = sock.read()
- self.__puts(html)
- pass
- #打印html 匹配數(shù)據(jù)
- def __puts(self,html):
- b = re.compile(r"]+?)
[\s]*target=([^<>]+?)>([^<>]+?)",re.I)- m = re.findall(b,html)
- #這里有encode 問題?,不知道,大家是否可以幫忙解答
- print m
- if __name__ == '__main__':
- url = "http://www.javaeye.com/blogs"
- p = ParseHTML(url)
- p.parse()
- if __debug__:
- print "debuging is %s" % __debug__
- print "regular" + "* " * 30
- #math
- str = "800-820-8800"
- m = re.match(r"(\d{3})-(\d{3})-(\d{4})", str)
- print "result : " ,m.groups()
- #split
- print "split : %s" % re.split('\W', 'Words, words, words.')
- #findall
- text = "He was carefully disguised but captured quickly
by police."- print "findall :%s" % re.findall(r"\w+ly",text)
- #sub
- text = "hello world!"
- print "sub:%s" % re.sub(r"\s+","--",text)
以上就是對Python正則表達(dá)式的詳細(xì)介紹。
【編輯推薦】
- Python腳本在游戲中尋找自己的知音
- Python語言腳本的安裝和配置
- Python語言在開發(fā)社區(qū)中的熱議簡介
- Python 代碼安裝相關(guān)步驟簡介
- 簡介Python代碼兩大實(shí)際應(yīng)用手冊
網(wǎng)站題目:Python正則表達(dá)式怎樣進(jìn)行Java中的使用
標(biāo)題URL:http://fisionsoft.com.cn/article/ccdcphc.html


咨詢
建站咨詢
