python 3.x - Escaping string arugments to subprocess calls in Windows -


why example one copy hello world clip board not example two?

# example 1 subprocess.check_output(["echo", "hello world", "|", "clip"], shell=true, stderr=subprocess.stdout)  # example 2 subprocess.check_output(["echo", "hello \n world", "|", "clip"], shell=true, stderr=subprocess.stdout) 

another issues example one copies hello world quotes around so:

"hello world" 

so, how copy text multiple lines clipboard without double-quotes?

as suggested @eryksun, solves issue:

p = subprocess.popen('clip.exe', stdin=subprocess.pipe, stdout=subprocess.pipe, universal_newlines=true) p.communicate('hello \n world') p.wait()