簡體   English   中英

perl to python ...我該怎么辦?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM