A
1. Common data types: integer, Float, Boolean, complex type, etc.
2 integer: an integer, similar to the Java BigInteger type, with unlimited length (limited to the total amount of virtual memory). Can be calculated in large numbers.
3 floating point: that is, decimal, (the only way for Python to differentiate between integral and floating point types is decimal.) Commonly used e notation (i.e. scientific notation, which represents particularly large and particularly small numbers)
4 Boolean type: a special integral type with true and False to denote "true" and "false" can be treated as integers. Ture equivalent to an integer value of 1,false equivalent to an integer value of 0. Note: It is very low to take the Boolean type as 1 and the calculation of the
Two
1. Functions related to data type: Int (), float (), str ().
2.int (): Converts a string and a floating-point number to an integer column:
>>>a= ' 520 '
>>>b=int (a)
>>>a,b
(' 520 ', 520)
>>>c=5.99
>>>d=int (c)
>>>c,d
(5.99,5) Note: Python is taking truncation processing, not rounding.
3.float (): Converts a string or integer to a floating-point (decimal) column:
>>>a= ' 520 '
>>>b=float (a)
>>>a,b
(' 520 ', 520.0)
>>>c=520
>>>d=float (c)
>>>c,d
(520,520.0)
4.STR (): Converts a number and other types to a string
Three.
Type () function:
>>>type (' 520 ')
<class ' str ' >
>>>type (5.20)
<class ' float ' >
>>>type (5E20)
<class ' float ' >
>>type (520)
<class ' int ' >
>>>type (True)
<class ' bool ' >
Isinstance (): First to determine the type of data; second specifies a data type
Isinstance () returns the value of a Boolean type according to the above two parameters true is type consistent, false is type inconsistent
, &N Bsp , &NB Sp , &NB Sp , &NB Sp small windbreaker
November 26, 2017
Day1.python Common data Types-----Brief Diary