The difference between None and [ ] and "" in python

Today, when I was working on the topic of the tree, when judging that the tree is empty, should the returned value be None or [] to raise doubts

In fact, you can take a look at the types of the three of them.

As shown in the figure, the three types are completely different,

None means that the value is an empty object, and a null value is a special value in Python, represented by None. None cannot be understood as 0, because 0 is meaningful, and None is a special null value.

[] means an empty list

'' '' means an empty string

Obviously there is a big difference between the three

At the same time, note that there is no NULL in python.

Guess you like

Origin blog.csdn.net/candice5566/article/details/123746897