【发布时间】:2019-03-28 07:30:43
【问题描述】:
我有一个 python 模块,其职责是插入时间戳。我有一个用例,我想在调用此模块中的函数时获取进程开始时间。
在这个模块的 Perl 等效项中,我使用 $^BASETIME, $^T 来获取进程的开始时间。 python中也有类似的方法吗?
我提到了这个问题 (How to retrieve the process start time (or uptime) in python)。除了使用ps还有其他方法吗?
import time
def get_process_start_time():
return time.time()
【问题讨论】:
-
该过程仍然与您链接的问题中的答案相同:How to retrieve the process start time (or uptime) in python。它们都不需要您将开始时间隔离到特定模块。
-
这个问题背后的意图是检查我们是否在 python 中支持 perl 特殊变量
标签: python python-2.7