(my_re2,use_match2), (my_re3,use_match3) ]: match = exp.match(line) 如果匹配: func(匹配) 休息 替代解决方案是Diez的测试对象。 HTH<ot>Isn''t it the third or fourth time this very same question pops up here ?Starts to look like a FAQ.</ot>The canonical solution is to iterate over a list of expression,functionpairs, ie:def use_match1(match):# code heredef use_match2(match):# code heredef use_match3(match):# code herefor exp, func in [(my_re1, use_match1),(my_re2, use_match2),(my_re3, use_match3)]:match = exp.match(line)if match:func(match)breakThe alternate solution is Diez''s Test object.HTH 这篇关于C-like赋值表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-28 19:26