[英]perl to python…how do I?
我正在嘗試學習python,但不太了解語法。 相當於:
my $string='this one this that this here ';
while($string=~/this\s+(.*?)\s+/g){
print $1."\n";
}
打印:
one
that
here
試試re
模塊。 我認為這是等效的,模擬了string
一些副作用:
import re
string = "this one this that this here "
for match in re.finditer(r"this\s+(.*?)\s+", string):
print match.group(1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.