python none_None关键字,带Python示例

python none

Python None关键字 (Python None keyword)

Note: None is not a keyword – we are just considering & writing it as a keyword which is a replacement of null (in C/C++).

注意: None不是关键字–我们只是考虑并将其编写为关键字,以替换null(在C / C ++中)。

"None" (case-sensitive) is an object of its own datatype, the NoneType, which is similar to null, it is used to define a null value to the variable or represents that a variable does not have any value at all.

“ None” (区分大小写)是其自己的数据类型对象, NoneType ,它类似于null,用于为变量定义一个null值或表示一个变量根本没有任何值。

None is a type of <class 'NoneType'>.

<class'NoneType'>的类型是None

Syntax:

句法:

    None

Example:

例:

    Input:
    a = None
    print("a: ", a);

    Output:
    a: None

Python code to demonstrate example of None keyword

Python代码演示None关键字示例

# python code to demonstrate example of 
# None keyword

# type of None
print("type of None: ", type(None))

# declaring a variable and initialize it with None
a = None
# printing value
print("a: ", a)

# checkng None in condition
if a == None:
    print("variable \'a\' contains None")
else:
    print("variable \'a\' does not contain None")

# assigning a value and rechecking the condition
a = 100
if a == None:
    print("variable \'a\' contains None")
else:
    print("variable \'a\' does not contain None")

Output

输出量

type of None:  <class 'NoneType'>
a:  None
variable 'a' contains None
variable 'a' does not contain None


翻译自: https://www.includehelp.com/python/none-keyword-with-example.aspx

python none

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值