精華區beta Python 關於我們 聯絡資訊
練習的程式,請各位多指教: --------------------------------------------------------------------------- #!/usr/bin/python # -*- coding: utf-8 -*- import sys import re import urllib2 #讀取第一個參數 word = sys.argv[1] #讀入網頁資料 content = urllib2.urlopen('http://tw.dictionary.yahoo.com/search?ei=UTF-8&p='+word).read() #將翻譯一筆筆秀出 for i in re.compile('<div class=pexplain>(.+?)</div>').findall(content): print i ----------------------------------------------------------------------------- BTW,有人知道re module中的finditer怎麼使用嘛?試了半天試不太出來呢 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.16.1.95