The size of bytes occupied by the type memory address of the view variable in Python
- 2021-07-03 00:27:09
- OfStack
Type, memory address, and size of bytes for viewing variables in Python
View the type of variable
# Take advantage of built-in type() Function
>>> nfc=["Packers","49"]
>>> afc=["Ravens","48"]
>>> combine=zip(nfc,afc)
>>> type(combine)
<class 'zip'>
View the memory address of the variable
# Use built-in functions id(), So 10 Binary display
>>> id(nfc)
2646554913160
>>> id(afc)
2646554913544
View the size of bytes occupied by variables
>>> import sys
>>> print(sys.getsizeof(combine))
64
>>> print(sys.getsizeof(nfc))
80
>>> print(sys.getsizeof(afc))
80
PS: Method for viewing variable memory address in python
In this paper, the method of viewing variable memory address in python is described as an example. Share it for your reference. The specific implementation method is as follows:
You can use id here
id(object) -> integer
Return the identity of an object. This is guaranteed to be unique among
simultaneously existing objects. (Hint: it's the object's memory address.)
I hope this article is helpful to everyone's Python programming.
id (x) Gets the memory address of the x variable (decimal)
Summarize
The above is the site introduced to you Python to see the type of variable memory address in the size of bytes, I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time!