python自动同步ntp时间
import os,time,ntplib
ntp_client = ntplib.NTPClient()
response = ntp_client.request("pool.ntp.org")
time_str = response.tx_time
ntp_date = time.strftime('%Y-%m-%d',time.localtime(time_str))
ntp_time = time.strftime('%X',time.localtime(time_str))
os.system('date {} && time {}'.format(ntp_date,ntp_time))
print("OK",ntp_date,ntp_time)