4
我想學習python,但不太明白語法。什麼是等價的:perl to python ...我怎麼樣?
my $string='this one this that this here ';
while($string=~/this\s+(.*?)\s+/g){
print $1."\n";
}
打印:
one
that
here
我想學習python,但不太明白語法。什麼是等價的:perl to 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)
這實際上很有趣。 –
@MK。請解釋這些騙子。 – agf
我發現Perl和「我不懂Python語法」有趣的組合。希望我沒有傷害任何人的感情。 –