Wuc*_*ron 7 python variables definition literals
我是Python的初学者,但我对文字和变量感到困惑.
这就是我对文字的了解: "a"+"b"
和变量: sentence="a"+"b"
tim*_*mss 13
文字是表示fixed(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)
Run Code Online (Sandbox Code Playgroud)
在任何编程语言中,文字都是一个常量值,而标识符可以改变它们的值。标识符可以存储文字并进一步处理它们。标识符是赋予变量的名称。
1、1.5、'a'、"abc"等是文字的示例。但是在语句中x=123,x 是一个变量,而 123 是一个 Literal。