Store output of subprocess.Popen call in a string

前端 未结 15 2201
一个人的身影
一个人的身影 2020-11-22 03:23

I\'m trying to make a system call in Python and store the output to a string that I can manipulate in the Python program.

#!/usr/bin/python
import subprocess         


        
15条回答
  •  伪装坚强ぢ
    2020-11-22 04:00

     import os   
     list = os.popen('pwd').read()
    

    In this case you will only have one element in the list.

提交回复
热议问题