Kiran Varghese Kiran Varghese - 7 months ago 43
Python Question

Why do these two command give different outputs?

Command 1:["echo","\"hw\""])



Command2 :["echo","""hw"""])




Your first command passes the quotes to the echo system command, and thus is equivalent to doing this on the command line:

$ echo "hw"

Your second command only passes the hw string (no quotes) to echo and is equivalent to the following:

$ echo hw

In your second command, you're using the docstring notation for strings, which is equivalent to "hw" as well as 'hw'.