+ -
当前位置:首页 → 问答吧 → Python的语法检查?

Python的语法检查?

时间:2010-12-01

来源:互联网

有可能没有?

if re.search("a", s) is not none:
   # ......
elif re.serach("b", s) is not none:
   # ......

由于我的x一直是a,所以这个脚本跑了好几个月也没问题,今天突然有一个非a值,才发现我的elif分支的search拼错了。囧


有没有办法检查出这种语法错误,用编译好像也不能查出来

import compileall
compileall.compile_dir('/tmp/test', force=True)

编译通过,没有错误

作者: Gubuntu   发布时间: 2010-12-01

,单元测试没做好

作者: starzhestarzhe   发布时间: 2010-12-01