The problem arises when I try to start by adding real time to my self-built web page.
I've previously known that Python has a module datetime for events and dates. The following import datetime and experiment.
>>> Import datetime
>>> Type (datetime)<class'module'>
It is known that datetime belongs to the module class. In addition, a similar time-dependent module also has the timing and calendar.
There is two kinds of the date and time objects: "Naive" and "aware".--here are three types of objects related to dates and times: natural objects and conscious objects .
A datetime module defines two constants: DateTime. Minyear and Datetime.maxyear, respectively, representing the minimum and maximum year that datetime can represent. wherein, Minyear = 1,maxyear = 9999.
There can also be constants in the ———————————————————————— module ————————————————————————————————
Explore DateTime. Minyear and Datetime.maxyear Source:
C:\Python33\Lib\datetime.py
def _cmp (x, y): return if Else if Else -1= 1= 9999# date.max.toordinal ()= [ None,to, from, to,,,,,,,,,,,,,,,,,, to, 0
NOTE: def _cmp (x, y): Single underline function.
A member variable that starts with a "single underline" is called a protection variable, meaning that only class objects and subclass objects can access these variables themselves;
A "double underline" begins with a private member, meaning that only the class object can access it, and the child object cannot access the data.
————————————————————————————————————————————————————————————————————
So,datetime is a module that looks at a. py file from the file system. Of course, the module can also be a folder with __init__.py.
- class datetime. Timedelta
These are the classes in the DateTime module, and the following are the inheritance relationships of the above classes:
object: Timedelta tzinfo timezone time date datetime
————————————————————————————————————————————————————————————————————
By using similar Object_name=datetime.datetime_class (ATTR1,ATTR2,....) , you can instantiate the class in the above DateTime module (instance).
The official documentation divides the DateTime class members into: Class methods, class attributes, instance method (Instance methods).
The difference between a class method and an instance method has the following code as an experiment:
Example: Class method Datetime.today ()
>>> a=datetime.datetime.today ()>>> Adatetime.datetime (2014, 8, 26, 19, 29, 27, 18840)print(a)2014-08-26 19:29:27.018840>>> datetime.datetime.today () Datetime.datetime (2014, 8, 26, 19, 29, 58, 992818)
Example Methods Datetime.date () and Datetime.replace ()
>>> a.date () #实例传入方法一datetime. Date (8, +)>>> Datetime.datet Ime.date (a) #实例传入方法二datetime. Date (8, b)>>> a.replace (2000,1,1) #实例传入方 FA Yi Datetime.datetime (1, 1, 18840)>>> datetime.datetime.replace (a,1993,5,4 ) #实例传入方法二datetime. DateTime (1993, 5, 4, 19, 29, 27, 18840)
Summarize:
- The class method may need to pass in a parameter, or it may not require a parameter, but the parameter is definitely not an instance of the class.
- Instance methods instead, you need to pass in an instance of a class as a parameter, with two (or more) methods.
This made me realize that the previous blog post was about the static methods of Python and the class member methods (http://www.cnblogs.com/Simon-xm/p/3890942.html).
Here the search shows that Python has, instance methods, static methods, class methods, class variables, instance variables. Address: http://www.cnblogs.com/Simon-xm/p/3935809.html
python--Explore Python's data schema from a datetime module