1. First of all, understand the concept of Python's objects:
In Python, everything is an object, all operations are on objects, so what is an object, 5 is an int object, 'oblong' is a str object, an exception is also an object, and in the abstract, a human, a cat, and enough is an object too!
For an object, then, it has characteristics that include both:
Attributes: to characterize it
Methodology: Behavior it has
So, object = attribute + method (actually, method is also an attribute, a callable attribute distinct from a data attribute)
Objects with the same properties and methods can be grouped together into a class, Classl. A class is like a blueprint, and multiple object instances can be created using a single class
I.e., humans, cats, and dogs are all mammals.
Classes are abstractions of objects and objects are instantiations of classes. Classes do not represent concrete things, while objects represent concrete things
Classes also have properties and methods.
2. Data types are also objects
In fact Pyhton has the concept of object only when it comes to object-oriented programming, whereas when it comes to procedural programming, we discuss data types the most.
Python provides the following basic data types: Boolean, Integer, Floating Point, String, List, Tuple, Set, Dictionary, etc.
A datatype can also be thought of as a "class".
Each datatype is an object and also has its own properties and methods
The difference between None and NULL (i.e., the null character) in the
Understanding the above concepts, it is not difficult to understand the difference between None and null
(1) is a different kind of data type
>>>type(None) <class 'NoneType'>
Indicates that the value is a null object. null is a special value in Python, denoted by None. none cannot be interpreted as 0, because 0 is meaningful, and None is a special null value.
>>>type('') <class ''str'>
You can assign None to any variable, and you can assign any variable to a None-worthy object.
(2) False in all cases.
>>> ff=None >>> if ff: print('ff is define')
Execution result: no printing!1
(3) Different properties
Use the dir() function to return a list of attributes, methods of the argument. If the argument contains the method dir(), the method will be called. If the argument does not contain dir(), the method will collect maximum information about the argument.
dir(None)
['__bool__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']1
dir('')
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']1
Summary:
This article explains the difference between None and NULL (i.e., the null character), as well as the concept of objects and classes in Python, and the use of type() and dir() functions.
This article on Python None and NULL (i.e., null characters) the difference between the article is introduced to this, more related to Python None and NULL content, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future!