Basic data types in python
1: Although the python variables need to be declared, but must be assigned when using
integer variable
float variable
character
2: a can to a plurality of variables, which may be a plurality of variable assignment to a plurality of
3: python3 in six standard data type
number (number)
= True. 1 * * = False 0 * division value (/) always returns a floating-point, integer used to obtain // operator * calculated during mixing, shaping would convert floating Python
String (String)
* String 'or' enclosed, while using \ escape special string * if you do not want backslash occurs, can be added in front of a string r represents the original string * index as the start value 0, - 1 start position to the end * + sign is connected string, and the asterisk * indicates a copy of the current string, immediately following the number of times the digital copy
List (list)
* list written between square brackets with a comma elements * and the same string, list may be indexed and sliced * list may be used to connect the + operator * list of elements can be varied
Tuple (tuple)
* Tuple with a list of similar, except that the elements of the tuple can not be changed, write tuple in parentheses. Elements separated by commas * tuples and indexes may also be sliced, as a method * Note special syntax rules tuple or a configuration comprising elements 0 * tuple may be spliced with the + operator
Sets (collections)
* Set does not need to be a repeat of the sequence, the basic function is to test and remove duplicate elements of membership
Dictionary (dictionary)
* Is a dictionary mapping type, identification dictionary by {}, which is built in a disordered (key): Value (value) of the set * Construction (key) must be immutable. Built in the same dictionary (key) must be unique * Create empty dictionary using {}
4: Conversion between type
* int (x, base = 10 ) x string or a number, base number hexadecimal, decimal floating-point to Integer Default * float integer to floating point * complex (1,2) is converted to the complex * str (10) converting the object to a string * repe () string to convert an object to the expression * repr (dict) string to convert an object to the expression * eval (str) used to calculate the effective expression in python string, returns an object * tuple (listi) into a tuple list * list () converts a list of tuples * set conversion set
This article is reproduced in https://www.py.cn/faq/python/11767.html