Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

python - Python中的null对象?(null object in Python?)

我如何在Python中引用null对象?

  ask by Lizard translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Python, the 'null' object is the singleton None .

(在Python中,'null'对象是单例None 。)

The best way to check things for "Noneness" is to use the identity operator, is :

(检查“无效”的最佳方法是使用身份运算符, is :)

if foo is None:
    ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...