电源变换适用于非独立源码
As we have discussed in the previous post (Python None keyword), that "None" is a keyword which can be used to assign a null value to a variable or to check whether a variable contains any value or not.
正如我们在上一篇文章中讨论的( Python None关键字 ), “ None”是可用于为变量分配空值或检查变量是否包含任何值的关键字。
Example:
例:
Here, we have 3 variables a, b and c, a is being assigned with "Hello", b is being assigned with "None" and c is being assigned with 10.
在这里,我们有3个变量a , b和c , a分配给“ Hello” , b分配给“ None” , c分配给10 。
We are testing whether variables have a value or None, if they have values, we are printing their values.
我们正在测试变量是否具有值或无,如果它们具有值,我们将打印其值。
# python code for not None test
# variable 1 with value
a = "Hello"
# variable 2 with None
b = None
# variable 3 with value
c = 10
# performing is not None test
if a is not None:
print("value of a: ", a)
else:
print("\'a\' contains None")
if b is not None:
print("value of b: ", b)
else:
print("\'b\' contains None")
if c is not None:
print("value of c: ", c)
else:
print("\'c\' contains None")
Output
输出量
value of a: Hello
'b' contains None
value of c: 10
翻译自: https://www.includehelp.com/python/not-none-test.aspx
电源变换适用于非独立源码