首页 新闻 赞助 找找看

python3.6.1 使用finditer函数问题

0
悬赏园豆:10 [已关闭问题] 关闭于 2017-08-15 17:52

根据《python核心编程》书中的例子程序如下:

import re
s = 'This and that.'
it = re.finditer(r'(th\w+)', s, re.I)
g = it.next()

按道理应该是能运行通过的,但是出现了如下问题:

大神们帮我看看是什么原因。

lqwh的主页 lqwh | 菜鸟二级 | 园豆:204
提问于:2017-08-15 17:45
< >
分享
所有回答(1)
0

我在https://stackoverflow.com/questions/28542497/iterparse-object-has-no-attribute-next网站里面找到了原因。

Assuming you are using Python3, the iterator syntax is next(context) instead of context.next()

是python版本的问题。

lqwh | 园豆:204 (菜鸟二级) | 2017-08-15 17:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册