博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python变量分配内存_Python | 声明任何变量而不分配任何值
阅读量:2532 次
发布时间:2019-05-11

本文共 1110 字,大约阅读时间需要 3 分钟。

python变量分配内存

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是一种动态编程语言,因此无需声明此类变量,它会在首次分配值时自动声明。

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 = None

Example:

例:

num = None

Let’s understand through a program:

让我们通过一个程序来理解:

# Python program to declare a # variable without assigning any value # declare variable num = None# print the valueprint "value of num: ", num# checking variableif (num==None):	print "Nothing"else:		print "Something"	# assign some valuenum = 100# print the valueprint "value of num: ", num# checking variableif (num==None):	print "Nothing"else:		print "Something"

Output

输出量

value of num:  None    Nothing    value of num:  100    Something

翻译自:

python变量分配内存

转载地址:http://nfazd.baihongyu.com/

你可能感兴趣的文章
代码片段收集
查看>>
vue-cli3创建项目时报错
查看>>
输入1-53周,输出1-53周的开始时间和结束时间
查看>>
实验二
查看>>
shell——按指定列排序
查看>>
crash 收集
查看>>
507 LOJ 「LibreOJ NOI Round #1」接竹竿
查看>>
UI基础--烟花动画
查看>>
2018. 2.4 Java中集合嵌套集合的练习
查看>>
精通ASP.NET Web程序测试
查看>>
vue 根据不同属性 设置背景
查看>>
51Nod1601 完全图的最小生成树计数 Trie Prufer编码
查看>>
Codeforces 1110D. Jongmah 动态规划
查看>>
android驱动在win10系统上安装的心酸历程
查看>>
优雅的程序员
查看>>
oracle之三 自动任务调度
查看>>
Android dex分包方案
查看>>
ThreadLocal为什么要用WeakReference
查看>>
删除本地文件
查看>>
FOC实现概述
查看>>