python none_None关键字,带Python示例
python none
Python None關(guān)鍵字 (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不是關(guān)鍵字–我們只是考慮并將其編寫為關(guān)鍵字,以替換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” (區(qū)分大小寫)是其自己的數(shù)據(jù)類型對象, NoneType ,它類似于null,用于為變量定義一個(gè)null值或表示一個(gè)變量根本沒有任何值。
None is a type of <class 'NoneType'>.
<class'NoneType'>的類型是None 。
Syntax:
句法:
NoneExample:
例:
Input:a = Noneprint("a: ", a);Output:a: NonePython code to demonstrate example of None keyword
Python代碼演示None關(guān)鍵字示例
# 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
總結(jié)
以上是生活随笔為你收集整理的python none_None关键字,带Python示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 哈尔滨看免疫性不孕症最好的医院推荐
- 下一篇: 夏普电视常见的故障?