最佳答案
我需要在本地主机上使用 Python 运行命令 date | grep -o -w '"+tz+"'' | wc -w
。我使用 subprocess
模块和使用 check_output
方法,因为我需要捕获相同的输出。
然而,这让我犯了一个错误:
Traceback (most recent call last):
File "test.py", line 47, in <module>
check_timezone()
File "test.py", line 40, in check_timezone
count = subprocess.check_output(command)
File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception-
OSError: [Errno 2] No such file or directory