品易云推流 关闭
文章详情页
文章 > Python基础教程 > Python代码中编译是什么

Python代码中编译是什么

Python 编译

头像

小妮浅浅

2021-06-15 10:38:582918浏览 · 0收藏 · 0评论

说明

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

2、当用户键入代码交给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代码中编译的介绍,通过结尾的例子,我们可以看出编译后代码的性能是比较好的。大家学会后也赶快用起来吧。更多Python学习指路:python基础教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图