<分区>
我是 Python 的初学者,但我对字面量和变量感到困惑。
这就是我对字面量的了解:"a"+"b"
和变量:sentence="a"+"b"
<分区>
我是 Python 的初学者,但我对字面量和变量感到困惑。
这就是我对字面量的了解:"a"+"b"
和变量:sentence="a"+"b"
最佳答案
文字是表示固定 (const
) 值的符号。
变量是与符号名称关联的存储位置(如果您愿意,可以指向)。
最好在使用中解释:
foo = bar(42)
^ ^ ^
| | |--- literal, 42 is *literally* 42
| |------- function, also represents "something" in memory
|------------- variable, named "foo", and the content may vary (is variable)
另一方面,标识符是在 python 语句中分配给变量的名称。
关于python - Python中的文字和变量有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16116446/
相关文章:
javascript - 有没有办法在javascript中的for循环的每次迭代中捕获变量的值?
javascript - 如何为此 javascript 库编写 typescript 定义文件?
python - 值错误: Timeseries already present in CollectorRegistry
python - 如何将 rfcomm shell 命令的结果放入 python 中的变量中?
function - (a -> a) 和 a -> a 之间的区别
python - travis-ci build on Python3.4 六个 urllib 不会安装