Output from subprocess.Popen

后端 未结 3 552
耶瑟儿~
耶瑟儿~ 2021-01-18 23:46

I\'ve been writing some python code and in my code I was using \"command\"

The code was working as I intended but then I noticed in the Python docs that command has

3条回答
  •  长情又很酷
    2021-01-19 00:31

    The variable output does not contain a string, it is a container for the subprocess.Popen() function. You don't need to print it. The code,

    import subprocess
    output = subprocess.Popen("ls -al", shell=True)
    

    works perfectly, but without the ugly : being printed.

提交回复
热议问题