-2

While executing the below script in the interactive prompt, there is an additional 0 is returned. Why is that 0 there?

>>> import os
>>> os.system('date')
Sun Oct  2 19:20:29 IST 2016  
0
Andrew Li
  • 55,805
  • 14
  • 125
  • 143
Nitheesh MN
  • 608
  • 8
  • 18

2 Answers2

3

Thats the exit status of the program, 0 normally means the program finished without error.

Raphael Roth
  • 26,751
  • 15
  • 88
  • 145
2

You are performing a system call. 0 is the return code of this call. If you are trying to just get the current time use: datetime.datetime.now()

squanto773
  • 494
  • 5
  • 12