Basic data types
Type(data) view data Types
ID (data) view memory address
1. Digital
A. Int ( integer number )
on the four- bit machine, the number of digits of the integer is the value range of -2**31~2**31-1, i.e. -2147483648~ 2147483647
on the system, the number of digits of the integer is 9223372036854775808, and the value range is -2**63~2**63-1. ~9223372036854775807
B.long (length integer number)
with Unlike the C language,python 's long integers do not refer to the positioning width, that is, Python does not limit the size of long integer values, but in fact, because of limited machine memory, we use a long integer value can not be infinite.
Attention:
1. since Python2.2 , if an integer overflow occurs, Python automatically converts the integer data to a long integer, so there is now no letter L after the long integer data It's not going to cause serious consequences.
2. There is no longer a long type in Python3 , all int
2. string
A. in Python , quoted characters are considered to be strings (quotation marks: single, double, and triple quotes)
B. strings can also be mathematically operated, but only by adding or multiplying, and the concatenation of strings can only be a string between the two, and cannot be spliced with numbers or other types
3, boolean value (bool)
The main use of logical judgment
There are only two values:
True ( true )
False ( false )
Practice:
Judging Boolean values
>>>true or Flase and flase
True
4. List
Can hold multiple values, each of which can correspond to any one data type
names=[' Alex ', ' Egon ', ' Lyndon '
to take the elements in the list, you need to pass the subscript, starting with 0
5. Dictionaries
Store values in a key:value way, and can hold multiple values
each value can also be any data type
but key must be an immutable data type
dic={' name ': ' Egon ', ' passwd ': 123}
The dictionary uses key to fetch value
variable data types (or non- hash data types):
The ID does not change
Type does not change
the value has changed.
Lists are mutable types, numbers and strings are immutable types
This article is from the "Lyndon" blog, make sure to keep this source http://lyndon.blog.51cto.com/11474010/1946066
Python Base---data types