问题描述
我是python的新手,因此是一个愚蠢的问题。
I am a complete newb to python, hence a silly question.
据我了解,在第一次执行* .py程序时,字节代码会创建到* .pyc中,并一直使用到* .py文件发生更改为止。
As i understand, upon first execution of a *.py program, byte code is created into *.pyc and used until a change in *.py file.
在项目中哪里可以找到此* .pyc字节码?
Where might this *.pyc bytecode be found in a project?
我想bin,但那里什么也没有
I would think bin, but nothing is there
推荐答案
为导入的模块创建了一个* .pyc文件,并将它们放置在包含.py文件的同一目录中。但是...没有为您的程序的主脚本创建.pyc文件。换句话说...如果在命令行上调用 python myscript.py,则myscript.py将没有.pyc文件。
A *.pyc file is created for imported modules, and they are placed in the same directory containing the .py file. However... no .pyc file is created for the main script for your program. In other words... if you call "python myscript.py" on the command line, there will be no .pyc file for myscript.py.
Python 2.x表现良好。但是,在Python 3.x中,.pyc文件保存在 __ pycache __
目录中。有关详细信息,请参见David Glick的答案。
This is how Python 2.x behaves. However, in Python 3.x the .pyc files are saved in a __pycache__
directory. See David Glick's answer for details.
这篇关于.pyc文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!