How to print time in python?
![](https://pythonpoint.net/wp-content/uploads/2020/12/What-is-method-in-python_-4-1024x576.jpg)
We can get the time by importing a library datetime.
from datetime import datetime t=datetime.now() current=t.strftime("%h:%m:%s") print(current)
![](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-948-1024x484.png)
import time t=time.localtime() current=time.strftime("%H:%M:%S",t) print(current)
![](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-950-1024x518.png)
This is how we can print time in python.
Subscribe
Login
Please login to comment
0 Discussion