亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python ,正則表達式問題

Python ,正則表達式問題

元芳怎么了 2018-07-04 09:09:05
#!/usr/bin/pythonimport reline = "Cats are smarter than dogs"matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I)if matchObj:print "matchObj.group() : ", matchObj.group()print "matchObj.group(1) : ", matchObj.group(1)print "matchObj.group(2) : ", matchObj.group(2)else:print "No match!!"以上實例執行結果如下:matchObj.group() : Cats are smarter than dogsmatchObj.group(1) : CatsmatchObj.group(2) : smarter請問, r'(.*) are (.*?) .*',這個是匹配什么東西,是如何匹配的?好像很復雜的樣子,另外matchObj.group(1)可以有輸出,填3的時候就出錯了?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 854 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號