Kiran Varghese Kiran Varghese - 1 year ago 70
Python Question

Why do these two command give different outputs?

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



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



Answer Source

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'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download