Python 3.3相当于'execfile'

Dea*_*ris 3 python keyword execfile python-3.x

我需要找到如何在Notepad ++中编写后打开我的.py文件.我发现界面比Python窗口更有用.

在一个教程中,我跟随着这个人使用

execfile(pathway)
Run Code Online (Sandbox Code Playgroud)

但是execfile在3.3中不起作用.

3.x中是否有等价的陈述?

vau*_*tah 6

打开文件,阅读文件,并将其内容传递给exec:

with open('file.py') as source_file:
    exec(source_file.read())
Run Code Online (Sandbox Code Playgroud)