Describe that the today function of the datetime class of the datetime module is used.
import datetime
datetime.datetime.today()
as a result
datetime.datetime(2020, 3, 12, 23, 21, 41, 756354)
Will be.
In the above example, it is troublesome to use module name.class name. In such a case, use not only import but also from to import. from module name import class name (or function name or variable name) Describe that the today function of the datetime class is used.
from datetime import datetime
datetiem.today()
The result is similar
datetime.datetime(2020, 3, 12, 23, 21, 41, 756354)
Will be.
If you use as, you can use the library name (module name) in any word you like.
import datetime as t
t.datetime.today()
The result is similar
datetime.datetime(2020, 3, 12, 23, 21, 41, 756354)
Will be.
Recommended Posts