Sometimes, we want to use execfile in Python 3.
In this article, we’ll look at how to use execfile in Python 3.
How to use execfile in Python 3?
To use execfile in Python 3, we call exec
.
For instance, we write
exec(open("./filename").read())
to open the ./filename file with open
and read it with read
.
And then we run the opened file with exec
.
Conclusion
To use execfile in Python 3, we call exec
.