
This article is the author's original, reproduced also please indicate the source.
This article only represents the author's own views, for reference only. If you have any objection, you are welcome to discuss.
Forrest
目录
1. Row connector
2. Object in python
-id()
-type()
-Example
Defination of object in python
Row connector intend to connect two rows as one row in syntax.
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:25:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> print("row-connector")
row-connector
>>> string = "abcdefghijklmnopqrstuvwxyz"
>>> string
'abcdefghijklmnopqrstuvwxyz'
>>> string_ = "abcdefgh"
SyntaxError: EOL while scanning string literal
>>> string2 = "abcdefgh
ijklmnopqrstuvwxy
z"
>>> string2
'abcdefghijklmnopqrstuvwxyz'
>>> array = [1, 34, 545, 67, 009, 4, 655303]
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
>>> array = [1, 34, 545, 67, 9, 4, 655303]
>>> array
[1, 34, 545, 67, 9, 4, 655303]
>>> array = [1, 3, 4
, 3, 4, 5, 3, 90]
>>> array
[1, 3, 4, 3, 4, 5, 3, 90]
>>>
As we all known, python is an objective programming language.
Let us see two functions:
This funciton intends to show the address code of an object.
This one intends to show the type of the object.
Futhermore, we could get more usages from the hint when you are coding.
>>> string = "abcdefghijklmnopqrstuvwxyz" >>> string 'abcdefghijklmnopqrstuvwxyz' >>> string2 = "abcdefgh ijklmnopqrstuvwxy z" >>> string2 'abcdefghijklmnopqrstuvwxyz' >>> array = [1, 34, 545, 67, 9, 4, 655303] >>> array [1, 34, 545, 67, 9, 4, 655303] >>> array = [1, 3, 4 , 3, 4, 5, 3, 90] >>> array [1, 3, 4, 3, 4, 5, 3, 90] >>> >>> id(array) 4360215104 >>> type(array)>>> id(string) 4350198288 # we can see here, the same string is from the same address! >>> id(string2) 4350198288 # we can see here, the same string is from the same address! >>> type(string) >>>
There is a funny findings, when you named, defined two variables with same value for example in the instance above the 'string' and 'string2' is the same content, and the address is same.
a block of memory, has its particular type and value, available for some relevant operations
The reference
Above example is from GaoQi sxt lesson video.