zoukankan      html  css  js  c++  java
  • python3+ 模块学习 之 subprocess

    subprocess

      模块方法: 

        call()

        check_call()

        check_output()

        以上三个方法用于创建一个子进程,父进程等待子进程结束。若shell = true, 则shell 参数以字符串形式给出,否则,则以序列的形式给出。

      Popen 对象:

        child = Popen((argsbufsize=-1executable=Nonestdin=Nonestdout=Nonestderr=Nonepreexec_fn=Noneclose_fds=True,shell=False

               cwd=Noneenv=Noneuniversal_newlines=Falsestartupinfo=Nonecreationflags=0restore_signals=True,

               start_new_session=Falsepass_fds=()))

            Use communicate() rather than .stdin.write.stdout.read or .stderr.read to avoid deadlocks due to any of the other OS pipe buffers         filling up and blocking the child process.

        对象方法:

          child.poll()              # 检查子进程状态

          child.kill()               # 终止子进程

          child.send_signal()        # 向子进程发送信号

          child.terminate()        # 中止子进程

          child.wait()       #等待子进程终止

          child.communicate()   #和子进程交互

          

  • 相关阅读:
    Mac 终端自动补全忽略大小写
    AtCoder ABC 155F Perils in Parallel
    AtCoder ABC 155E Payment
    AtCoder ABC 155D Pairs
    AtCoder ABC 154F Many Many Paths
    牛客 边界都是1的最大正方形大小
    牛客 打印N个数组整体最大的Top K
    牛客 数组中子数组的最大累乘积
    牛客 在数组中找到一个局部最小的位置
    牛客 子矩阵最大累加和问题
  • 原文地址:https://www.cnblogs.com/tigerm/p/6117887.html
Copyright © 2011-2022 走看看