-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
  • 51,385
  • 12
  • 117
  • 139
Nitheesh MN
  • 558
  • 7
  • 17

2 Answers2

3

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

Raphael Roth
  • 25,362
  • 13
  • 78
  • 128
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
  • 484
  • 4
  • 12