如果解释 Python,什么是 .pyc 文件? [英] If Python is interpreted, what are .pyc files?

查看:63
本文介绍了如果解释 Python,什么是 .pyc 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经了解到 Python 是一种解释型语言...
但是,当我查看我的 Python 源代码时,我看到了 .pyc 文件,Windows 将这些文件标识为已编译的 Python 文件".

I've been given to understand that Python is an interpreted language...
However, when I look at my Python source code I see .pyc files, which Windows identifies as "Compiled Python Files".

这些是从哪里来的?

推荐答案

它们包含字节码,这是 Python 解释器将源代码编译为的内容.然后这段代码由 Python 的虚拟机执行.

They contain byte code, which is what the Python interpreter compiles the source to. This code is then executed by Python's virtual machine.

Python 的文档解释了这样的定义:

Python's documentation explains the definition like this:

Python 是一种解释型语言,因为与编译的相反,尽管区别可能是模糊的,因为字节码编译器的存在.这意味着源文件可以不显式直接运行创建一个可执行文件,然后运行.

Python is an interpreted language, as opposed to a compiled one, though the distinction can be blurry because of the presence of the bytecode compiler. This means that source files can be run directly without explicitly creating an executable which is then run.

这篇关于如果解释 Python,什么是 .pyc 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆