The following is the code:
import os
#f=os.popen('date -d @1358193598 +%m/%d/%y')
f=os.popen('date')
print(f)
I tied both ways, and it gave me an error of "broken pipe". Do you happen to know how to deal with this situation? I also tried to use the subprocess module, and it does not work either. The error message is as the following:
Traceback (most recent call last):
File "t_2.py", line 23, in <module>
dates.append(transfer_date_format(raw_date))
File "t_2.py", line 6, in transfer_date_format
stdin=subprocess.PIPE)
File "/usr/lib64/python2.6/subprocess.py", line 639, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
os.system(it usesPATHenv). But why do you need it? There is an API in Python for datesdatetimemodule