I'm trying to print today's date using os.sytem
and commands.getoutput
using python.
My code is :
import os, commands
print os.system("date +%Y%m%d%T")
print commands.getoutput("date +%Y%m%d%T")
=========Ouput :-=============
Case 1:
./test.py
First print statement's O/P:
2014071713:25:21
0
Second print statement's O/P:
2014071713:25:21
Case 2:
I tried trace using import pdb;pdb.set_trace()
print os.system("date +%Y%m%d%T")
(Pdb) n
2014071713:25:21
0
print commands.getoutput("date +%Y%m%d%T")
(Pdb) n
2014071713:31:29
--Return--
Why first print
statement appending 0
in both the cases and second print
statement is not appending anything in case 1
but it is appending --Return--
in case 2
?
I know there are some modules for date / time
in python but I want know why it is appending those extra strings in output ?