2015年9月9日 星期三

re module and python regular expression

發現臺北的wifi覆蓋率非常高,在光華商場外也可以坐者上網!

今天在寫到習題:
Write a program that prints the number of times the string 'bob' occurs in s. For example, ifs = 'azcbobobegghakl', then your program should print
Number of times bob occurs is: 2
    在找尋方法時發現了所謂的re module,其功能可以用來做文本檢索和搜尋,其中在篩選的條件必須使用所謂的 regular expression這種使用metacharacter組合成的小語言,可用來幫助參數的輸入,在閱讀python documents的章節how to regular expression 時,深刻地這功能好神奇喔!搞不好可以用來寫crawler用!
    裏頭有一些有趣的function需要好好研究一番,且做一些例句來玩玩:
  • re.search
  • re.match
  • re.findall





0 意見 :

張貼留言