小编eog*_*lan的帖子

如何使用Python ntplib将ntp服务器时间降低到毫秒精度?

我正在创建一个python模块,该模块将输出所选NTP池服务器的时间到毫秒精度,以此作为显示服务器时间戳变化的练习。到目前为止,我已经能够将原始服务器时间戳打印到2秒钟的精度内,但是如何获得毫秒精度呢?

ntp_pool = '0.pool.ntp.org', \
       'uk.pool.ntp.org', \
       'ie.pool.ntp.org'

def get_ntp_time():
    for item in ntp_pool:
        call = ntplib.NTPClient()
        response = call.request(item, version=3)
        print(time.ctime(response.orig_time))
Run Code Online (Sandbox Code Playgroud)

python ntp

4
推荐指数
1
解决办法
4424
查看次数

标签 统计

ntp ×1

python ×1