问题描述
|
我们有
matches = re.findall(r\'somewhat\',\'somewhere\')
我们可以简化一下吗
if len(matches) > index:
return matches[index]
else:
return \'default\'
要么
return matches[index] if len(mathes) > index else \'default\'
类似于JS \
return matches[index] || \'default\'
我们可以简单地使用
return \'somewhere\'.match(/somewhat/)[index] || \'default\'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)