python - Why do these two command give different outputs? -
command 1:
subprocess.call(["echo","\"hw\""])
output:
"hw"
command2 :
subprocess.call(["echo","""hw"""])
output:
hw
your first command passes quotes echo
system command, , equivalent doing on command line:
$ echo "hw"
your second command passes hw
string (no quotes) echo
, equivalent following:
$ echo hw
in second command, you're using docstring notation strings, equivalent "hw"
'hw'
.
Comments
Post a Comment