加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何从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

阅读文档的详细信息:-)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读