如何从IDLE交互式shell运行python脚本?
发布时间:2020-12-15 16:28:08 所属栏目:安全 来源:网络整理
导读:如何在IDLE交互式shell中运行python脚本? 以下引发错误: python helloworld.pySyntaxError: invalid syntax 内置功能: execfile execfile('helloworld.py') 自2.6:popen后弃用 import osos.popen('python helloworld.py') # Just run the programos.pope
如何在IDLE交互式shell中运行python脚本?
以下引发错误: >>> python helloworld.py SyntaxError: invalid syntax
内置功能:
execfile
execfile('helloworld.py') 自2.6:popen后弃用 import os os.popen('python helloworld.py') # Just run the program os.popen('python helloworld.py').read() # Also gets you the stdout 预先使用:subprocess import subprocess subprocess.call(['python','helloworld.py']) # Just run the program subprocess.check_output(['python','helloworld.py']) # Also gets you the stdout 阅读文档的详细信息:-) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |