为什么不每增加5秒调用一次time.localtime()?

时间:2019-11-09 18:40:51

标签: python python-3.x time

我正在将数据点写入数据库,并具有创建点的循环。我有sleep(5)是为了将时间增加5秒。以下是相关的代码块,尽管实际上仅与时间相关的行很重要:

for i in range(0,100):
    points = []
    #local = time.localtime()
    for x in range(0,5):
        points.append(Point("biz_intel").tag("region", random.choice(regions)) \
                            .tag("app",random.choice(apps)) \
                            # .tag("host",host) \
                            .field("user_sessions", random.choice(user_sessions)) \
                            .field("num_transactions",random.choice(num_xactions)) \
                            .time(int(time.mktime(time.localtime()))))
        #print(local)

        write_api.write(bucket=bucket, org=org, record=points)
        # print(points[0].time())
        sleep(5)

每隔5秒,我就将相同的unix时间戳打印到第二个。我如何确保它增加?我想每次简单地调用它会改变时间戳?

0 个答案:

没有答案