Home>Article>Backend Development> What are python data types
When understanding basic data types, what are the basic data types we need to know? Number int, Boolean value bool, string str, list list, tuple tuple, dictionary dict, etc.
##Number ---> int class(Recommended learning:Python video tutorial)
Of course, for numbers, Python’s number types include int, long, float, complex, and Boolean Values (0 and 1), here we only introduce the integer type. In Python2, the size of the integer is limited, that is, when the number exceeds a certain range, it is no longer an int type, but a long integer. In Python3, no matter what the size of the integer is, , collectively called integer type int.Boolean value --->bool class
For Boolean value, there are only two results, True and False, which respectively correspond to binary 0 and 1. There are too many values of True, we only need to know what the values of False are---》None, empty (i.e. [ ]/( ) /" "/{ }), 0;String --->str class
About string, it is the most commonly used data type in Python and has many uses. We can use single quotes '' or double quotes "" to create a string. Strings cannot be modified. All about characters, we can introduce strings from aspects such as indexing, slicing, length, traversal, deletion, splitting, clearing whitespace, case conversion, determining what starts with, etc.List --->list class
A list is composed of a series of elements arranged in a specific order. Its elements can be any data Types include numbers, strings, lists, tuples, dictionaries, Boolean values, etc., and their elements are also modifiable.Tuple --->tuple class
A tuple is an unmodifiable list. Its characteristics are similar to those of list. It is identified using parentheses instead of square brackets.Dictionary --->dict class
The dictionary is a series of key-value pairs, each key-value pair is separated by commas, and each key Corresponds to a value, which can be accessed by using a key. disorderly. The definition of the key must be immutable, that is, it can be a number, a string, a tuple, a Boolean value, etc.Set-->set class
About the definition of set: In my opinion, a set is like a basket, you can store things in it You can also get things from it, but these things are disordered, and it is difficult for you to specify to get a certain thing separately; at the same time, it can filter through certain methods to get the part of the things you need. Therefore, sets can be created, added, deleted, and relationally operated. Characteristics of collections:Python Tutorialcolumn to learn!
The above is the detailed content of What are python data types. For more information, please follow other related articles on the PHP Chinese website!