是否可以导入已编译的python文件? [英] Is it possible to import a compiled python file?

查看:142
本文介绍了是否可以导入已编译的python文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法弄清楚如何将已编译的.pyc模块导入到我的代码中,以便我可以在我的主脚本中使用它。这甚至可能吗?

I can't seem to figure out how to import a compiled .pyc module into my code so I can use it within my main script. Is this even possible?

推荐答案

如果有foo.pyc,导入foo将自动使用foo.pyc是否存在foo.py或不

If there is foo.pyc, import foo will automatically use foo.pyc whether foo.py exists or not

(如果foo.py更新,则会被使用)

(If foo.py is newer, it will be used)

http://docs.python.org/tutorial/modules.html

这篇关于是否可以导入已编译的python文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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