perl to python …我该怎么办?
发布时间:2020-12-16 06:18:26 所属栏目:大数据 来源:网络整理
导读:我正在尝试学习 python,但不太了解语法.相当于: my $string='this one this that this here ';while($string=~/thiss+(.*?)s+/g){ print $1."n"; } 打印: onethathere 解决方法 试试re模块.我认为这是等效的,模拟了字符串的一些副作用: import restrin
我正在尝试学习
python,但不太了解语法.相当于:
my $string='this one this that this here '; while($string=~/thiss+(.*?)s+/g){ print $1."n"; } 打印: one that here 解决方法
试试re模块.我认为这是等效的,模拟了字符串的一些副作用:
import re string = "this one this that this here " for match in re.finditer(r"thiss+(.*?)s+",string): print match.group(1) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |