Python代码中编译是什么

541次阅读
没有评论

Python代码中编译是什么

Python代码编译说明

在执行Python代码时,在Python解释器用四个过程“拆解”我们的代码,最终被CPU执行返回给用户。

首先当用户键入代码交给Python处理的时候会先进行词法分析,例如用户键入关键字或者当输入关键字有误时,都会被词法分析所触发,不正确的代码将不会被执行。

Python代码编译实例

#!/usr/bin/env python
import re
from time import ctime
def run():
        pattern='case'
        rere_obj=re.compile(pattern)
        infile=open('/etc/rc.subr','r')
        match_count=0
        lines=0
        for line in infile:
                match=re_obj.search(line)
                if match:
                        match_count+=1
                lines+=1
        return (lines,match_count)
if __name__=='__main__':
        print('starting at:',ctime())
        lines,match_count=run()
        print "LINES:",lines
        print "MATCHS:",match_count
        print('ending at:',ctime())

Python代码中编译的介绍,通过结尾的例子,我们可以看出编译后代码的性能是比较好的。大家学会后也赶快用起来吧。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-04-27发表,共计782字。
新手QQ群:570568346,欢迎进群讨论 Python51学习