1. 程式人生 > >python re的findall和finditer

python re的findall和finditer

nbsp find info fin log style pri pytho ali

記錄一個現象:

  今天在寫程序的時候,發現finditer和findall返回的結果不同。一個為list,一個為iterator。

技術分享圖片

  紅色箭頭的地方,用finditer寫的時候,print(item.group())時,返回這樣的結果。

技術分享圖片

  而用findall寫的時候,結果是這樣子。

技術分享圖片

  查了資料才明白,參考:http://blog.csdn.net/wali_wang/article/details/50623991

技術分享圖片

python re的findall和finditer