📜  Python无关键字

📅  最后修改于: 2022-05-13 01:55:29.926000             🧑  作者: Mango

Python无关键字

None 用于定义空值。它与空字符串、False 或零不同。它是类 NoneType 对象的数据类型。

将 None 值分配给变量是将其重置为原始空状态的一种方法。

示例 1:

Python3
# we will check the type of None
print(type(None))


Python3
# declaring a variable as None
var = None
  
# checking it's value
if var is None:
    print("var has a value of None")
else:
    print("var has a value")


输出

示例 2:

蟒蛇3

# declaring a variable as None
var = None
  
# checking it's value
if var is None:
    print("var has a value of None")
else:
    print("var has a value")
输出
var has a value of None

注意:如果函数不返回任何内容,则在Python中返回 None 。