subprocess.call

前端 未结 3 835
慢半拍i
慢半拍i 2020-12-10 21:48

I am new to the subprocess.call function and I have tried different combinations of the same call but it is not working.

I am trying to execute the following command

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 22:16

    example:

    subprocess.call(['ps','aux'])
    lines=subprocess.check_output(['ls','-al'])
    line_list = lines.split('\n')
    
    or
    
    handle = subprocess.Popen('ls',stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True)
    handle.stdout.read()
    

提交回复
热议问题