我正在创建一个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)