微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

`re.finditer` 什么时候可以不返回任何东西,而 string.index 可以?

如何解决`re.finditer` 什么时候可以不返回任何东西,而 string.index 可以?

简单地说,

In [9]: [m.start() for m in re.finditer(answer_text,context)]
Out[9]: []

In [10]: context.index(answer_text)
Out[10]: 384

如您所见,re.finditer 不会返回匹配项,但 index 方法会返回。这是预期的吗?

In [18]: context
Out[18]: 'fight for My Way (; lit. "Third-Rate My Way") is a South Korean television series starring Park SEO-joon and Kim Ji-won,with Ahn Jae-hong and Song Ha-yoon. It premiered on May 22,2017 every Monday and Tuesday at 22:00 (KST) on KBS2. Kim Ji-won (Hangul: 김지원 ; Hanja: 金智媛 ; born October 19,1992) is a South Korean actress. She gained attention through her roles in television series "The Heirs" (2013),"Descendants of the Sun" (2016) and "fight for My Way" (2017). Yellow Hair 2 () is a 2001 South Korean film,written,produced,and directed by Kim Yu-min. It is the sequel to Kim\'s 1999 film "Yellow Hair",though it does not continue the same story or feature any of the same characters. The original film gained attention when it was refused a rating due to its sexual content,requiring some footage to be cut before it was allowed a public release. "Yellow Hair 2" attracted no less attention from the casting of transsexual actress Harisu in her first major film role. Ko Joo-yeon (born February 22,1994) is a South Korean actress who has gained attention in the Korean film industry for her roles in "Blue Swallow" (2005) and "The Fox Family" (2006). In 2007 she appeared in the horror film "Epitaph" as Asako,a young girl suffering from overbearing nightmares and aphasia,becoming so immersed in the role that she had to deal with sudden nosebleeds while on set. Kyu Hyun Kim of "Koreanfilm.org" highlighted her performance in the film,saying,"[The cast\'s] acting thunder is stolen by the ridiculously pretty Ko Joo-yeon,another Korean child actress who we dearly hope continues her film career." Kim Ji-won (Hangul:\xa0김지원 ; born December 21,1995),better kNown by his stage name Bobby (Hangul:\xa0바비 ) is a Korean-American rapper and singer. He is kNown as a member of the popular South Korean boy group iKON,signed under YG Entertainment. Descendants of the Sun () is a 2016 South Korean television series starring Song Joong-ki,Song Hye-kyo,Jin Goo,and Kim Ji-won. It aired on KBS2 from February 24 to April 14,2016,on Wednesdays and Thursdays at 22:00 for 16 episodes. KBS then aired three additional special episodes from April 20 to April 22,2016 containing highlights and the best scenes from the series,the drama\'s production process,behind-the-scenes footage,commentaries from cast members and the final epilogue. What\'s Up () is a 2011 South Korean television series starring Lim Ju-hwan,Daesung,Lim Ju-eun,Oh Man-SEOk,Jang Hee-jin,Lee Soo-hyuk,Kim Ji-won and Jo Jung-suk. It aired on MBN on Saturdays to Sundays at 23:00 for 20 episodes beginning December 3,2011. The 2016 KBS Drama Awards (),presented by Korean broadcasting System (KBS),was held on December 31,2016 at KBS Hall in Yeouido,SEOul. It was hosted by Jun Hyun-moo,Park Bo-gum and Kim Ji-won. Gap-dong () is a 2014 South Korean television series starring Yoon Sang-hyun,Sung Dong-il,Kim Min-jung,Kim Ji-won and Lee Joon. It aired on cable channel tvN from April 11 to June 14,2014 on Fridays and Saturdays at 20:40 for 20 episodes. Kim Ji-won (Hangul: 김지원; born 26 February 1995) is a South Korean female badminton player. In 2013,Kim and her national teammates won the Suhadinata Cup after beat Indonesian junior team in the final round of the mixed team event. She also won the girls\' doubles title partnered with Chae Yoo-jung.'

In [19]: answer_text
Out[19]: '"The Heirs" (2013)'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?