Understanding python subprocess.check_output's first argument and shell=True

后端 未结 2 2061
逝去的感伤
逝去的感伤 2020-11-28 15:08

I\'m confused on how to correctly use Python\'s subprocess module, specifically, the check_output method\'s first argument and the shell option. Check out the

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 16:04

    Anytime you use shell=True, you enter as the first argument to check_output a string in quotes that represents what you normally enter into a shell. "On Unix with shell=True, the shell defaults to /bin/sh." This gives you all the shell features. "This means that the string must be formatted exactly as it would be when typed at the shell prompt." See Popen

提交回复
热议问题