【问题标题】:When a python script is executed inside a python script, I do not get the complete output在 python 脚本中执行 python 脚本时,我没有得到完整的输出
【发布时间】:2017-08-17 11:48:38
【问题描述】:

在 python 脚本中执行 python 脚本时,我没有得到完整的输出。就我而言:

os.system('python -u capture.py > capture.log &')

其中 capture.py 将捕获数据包并将其提供给 capture.log。

Capture.py 将继续每 100 秒发送一次数据包。我看不到文件的完整输出。只有初始捕获被放入 capture.log 因为 capture.py 在一段时间后不会捕获任何数据包。

但是,当我在 bash 提示符下通过“python -u”执行相同的脚本时,它可以工作。

【问题讨论】:

  • 您的脚本在打印时是否刷新输出?
  • 为什么要像这样从 Python 运行 Python 脚本?

标签: python file subprocess shfileoperation


【解决方案1】:

您不能用io.system(...) 开始subprocess
阅读文档:os.system

你已经使用module-subprocess

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-21
    • 2015-10-14
    相关资源
    最近更新 更多