Home > Backend Development > Python Tutorial > What is the difference between null and none in python

What is the difference between null and none in python

清浅
Release: 2019-03-05 13:27:15
Original
20065 people have browsed it

The difference between none and null in Python is: none can be regarded as a specific value used to initialize variables, while null means that null is not a value and is not bound to any value and the storage space does not store a value

All operations in Python are based on objects. Objects have two characteristics: attributes and methods. Grouping objects with the same properties and methods together is called a class. Multiple objects can be created using one class. Classes are instantiations of objects, and objects represent concrete things. This is the concept of python objects. Today I will introduce the difference between none and null values ​​​​in Python objects. It has a certain reference effect and I hope it will be helpful to everyone.

What is the difference between null and none in python

[Recommended course: Python Tutorial]

The meaning of None

As shown in the figure below, None means none. It is an object of the NoneType class. You can think of it as a specific value. Because it is a specific value, it can be used to initialize variables, can be used as the return value of many functions under certain abnormal inputs, and can be used as a placeholder for the model input sample number variable in tensorflow's placeholder variable. None is both present and absent. The presence is reflected in the fact that it is a specific value, for example, it can assign a value to variable a; the absence is reflected in None. What it wants to tell you is that the current variable a is bound to a value that is meaningless and has no value. .

What is the difference between null and none in python

The meaning of Null

Null means empty. It is not a value, which is different from None. In scripting languages ​​​​such as Python, variables and values ​​are bound. If a variable is Null, it actually means that it is not bound to any value, which means that the variable is not actually defined; in Java, C, In compiled languages ​​​​such as C, when we say that a variable is Null, it means that the memory space pointed to by the variable does not store any value, not even the residual value of the last time the memory space was used.

Summary: The above is the entire content of this article, I hope it will be helpful to everyone.

The above is the detailed content of What is the difference between null and none in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template