As we said before, Python has been free and open since it was born. Today, a large number of modules have been created. So here's the question, what's the module?
For Python, a module is a collection of several features.
A module has its own properties, just like a person who has his or her name, height, weight, gender ...
A module also has its own method. The so-called method is what this module can do. Give me a chestnut-_-!!
1 Import Time 2 a=time.time ()3print(a)
Analysis:
1) since it is a module, only in the import (some modules need to install themselves, but also involved in the package dependencies, will be discussed later). Format is: Import module name
The above is the import of time (date and timeframe module).
2) Then create a new variable A, and assign a value. What is the value of the assignment? Time.time, the first time is the module name, the middle is separated by a dot, and the next time is the method name in the module.
3) Print a
Let's look at the print results together.
1 Import Time 2 >>> a=time.time ()3print(a)4 1522146472.0563416
Here Time.time () returns a value in units of "seconds". Here, starting from zero January 1, 1970, the total number of seconds to the current time.
Second, if you want to know what the properties of a module, which methods, you can import imports first, and then use the DIR () this command.
1>>>Import Time2>>>dir (time)3['_struct_tm_items','__doc__','__loader__','__name__','__package__','__spec__','Altzone','Asctime','Clock','CTime','Daylight','Get_clock_info','gmtime','localtime','Mktime','monotonic','Perf_counter','Process_time','Sleep','strftime','Strptime','Struct_time',' Time','TimeZone','Tzname']
In the third row, the ' __doc__ ' format is the property of this module, and the ' clock ' format is the method of this module.
Advanced first Lesson Python module introduction