Python 3 中 execfile 的替代方法是什么? [英] What is an alternative to execfile in Python 3?
本文介绍了Python 3 中 execfile 的替代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎他们在 Python 3 中取消了通过删除 execfile()
来快速加载脚本的所有简单方法
It seems they canceled in Python 3 all the easy way to quickly load a script by removing execfile()
是否有明显的替代方案?
Is there an obvious alternative I'm missing?
推荐答案
根据文档,而不是
execfile("./filename")
使用
exec(open("./filename").read())
见:
这篇关于Python 3 中 execfile 的替代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文