使用Python查找系统时间和Internet时间之间的偏移量

Jon*_*han 2 python systemtime

您如何使用Python从各种Internet时间源找到本地OS系统时间和Internet时间之间的时间偏移?

phi*_*hag 5

使用ntplib.从手册开始:

>>> import ntplib
>>> c = ntplib.NTPClient()
>>> response = c.request('europe.pool.ntp.org', version=3)
>>> response.offset
-0.143156766891
Run Code Online (Sandbox Code Playgroud)