python变量分配内存_Python | 声明任何变量而不分配任何值
python變量分配內(nèi)存
Since, Python is a dynamic programming language so there is no need to declare such type of variable, it automatically declares when first time value assign in it.
由于Python是一種動態(tài)編程語言,因此無需聲明此類變量,它會在首次分配值時自動聲明。
Still, this is a common question asked by many programmers that can we declare any variable without any value?
盡管如此,這是許多程序員提出的一個常見問題, 我們可以聲明沒有任何值的任何變量嗎?
The answer is: "Yes! We can declare such type of variable". To declare a variable without any variable, just assign None.
答案是:“是!我們可以聲明這種類型的變量” 。 要聲明不帶任何變量的變量,只需分配None即可 。
Syntax:
句法:
variable_name = NoneExample:
例:
num = NoneLet’s understand through a program:
讓我們通過一個程序來理解:
# Python program to declare a # variable without assigning any value # declare variable num = None# print the value print "value of num: ", num# checking variable if (num==None):print "Nothing" else: print "Something"# assign some value num = 100# print the value print "value of num: ", num# checking variable if (num==None):print "Nothing" else: print "Something"Output
輸出量
value of num: NoneNothingvalue of num: 100Something翻譯自: https://www.includehelp.com/python/declare-any-variable-without-assigning-any-value.aspx
python變量分配內(nèi)存
總結(jié)
以上是生活随笔為你收集整理的python变量分配内存_Python | 声明任何变量而不分配任何值的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dnf船长的戒指没用了?
- 下一篇: 怪物猎人崛起配信任务怎么下载