Use ntplib:
The following should work on both Python 2 and 3:
import ntplib
from time import ctime
c = ntplib.NTPClient()
response = c.request('pool.ntp.org')
print(ctime(response.tx_time))
Output:
Fri Jul 28 01:30:53 2017
More Related Contents:
- Python random.choice same output
- Are Python variables pointers? Or else, what are they?
- How to convert string to binary?
- How to run multiple while loops at a time in Python
- Automatically create requirements.txt
- python replace single backslash with double backslash
- Calculate weighted average using a pandas/dataframe
- Upload Image using POST form data in Python-requests
- Ambiguity in Pandas Dataframe / Numpy Array “axis” definition
- Axes class – set explicitly size (width/height) of axes in given units
- Revert the `–no-site-packages` option with virtualenv
- Python 3.4.0 with MySQL database
- Using while in list comprehension or generator expressions
- Logging setLevel is being ignored
- How to split a string by commas positioned outside of parenthesis?
- What all things happens inside pygame when I press a key? When to use pygame.event==KEYDOWN
- Behaviour of raw_input()
- List as a member of a python class, why is its contents being shared across all instances of the class?
- Sort a list with a custom order in Python
- How to process requests from multiiple users using ML model and FastAPI?
- String-based enum in Python
- making matplotlib scatter plots from dataframes in Python’s pandas
- Concatenation of many lists in Python [duplicate]
- How do I call a Django function on button click?
- Currying decorator in python
- get first and last values in a groupby
- Is there a MATLAB accumarray equivalent in numpy?
- How to get most informative features for scikit-learn classifier for different class?
- Image overlay in 3d plot
- Python pandas equivalent for replace