I have written this simple Python script that finds the current date and time:
import subprocess
time = subprocess.Popen('date')
print 'It is ', str(time)
When I run the program, I get the following:
It is <subprocess.Popen object at 0x106fe6ad0>
Tue May 24 17:55:45 CEST 2016
How can I get rid of this part in the output? <subprocess.Popen object at 0x106fe6ad0>
On the other hand, if I use call()
, as follows:
from subprocess import call
time = call('date')
print 'It is ', str(time)
I get:
Tue May 24 17:57:29 CEST 2016
It is 0
How can I get the Tue May 24 17:57:29 CEST 2016
come in place of 0
. And, why do we get 0
in the first hand?
Thanks.