Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Briefly introduce several data types in Python.
Briefly introduce several data types in Python.
Data type is the basic attribute of every programming language. Only by giving data a clear data type can a computer process data. Therefore, it is very necessary to use the correct data type. The following data types are commonly used in Python programming:

A, digital type

Python's number types mainly include int (integer), long (long integer) and float (floating point), but there is no long type in Python3.

1, int (integer)

On a 32-bit computer, the number of digits of an integer is 32, and the range of values is-231~1,that is,-2147483648 ~ 214748364; On a 64-bit system, the number of digits of an integer is 64, and the range of values is -263~263- 1, that is, 922337203685475808 ~ 92237203685475807.

2.long (long integer)

Python long integer does not specify bit width, but due to the limited memory of the machine, it is impossible to use long long integer value indefinitely.

3.float (floating point type)

Floating-point type is a number with a decimal point, and its precision is related to the machine.

4. Complex (complex)

Python also supports complex numbers, which are composed of real parts and imaginary parts, and can be represented by a+bj or complex numbers (a, b). The real part a and imaginary part b of a complex number.

Are all floating-point types.

Second, the string

In Python, all quoted characters are considered as strings, which can be declared in three ways: single quotation mark, double quotation mark and triple quotation mark; There are two data types of strings in Python, namely str type and unicode type. Str type adopts ASCII encoding, which cannot represent Chinese, and unicode type adopts unicode encoding, which can represent any character, including Chinese and other languages.

Third, Boolean type.

Like other programming languages, Python Boolean types are also used for logical operations and have two values: True (true) and False (false).

Fourth, the list

List is the most commonly used data type in Python. You can put any data type into a collection, and you can create, find, slice, add, modify, delete, cycle and sort the collection.

Verb (abbreviation for verb) tuple

A tuple, like a list, is a sequence. Unlike lists, tuples cannot be modified. Tuples are marked with "()", and internal elements are separated by commas.

Dictionary of intransitive verbs

Dictionary is a collection of key-value pairs, and it is the most flexible built-in data structure type in Python except list. List is an ordered collection of objects, while dictionary is an unordered collection of objects.

Seven. assemble

A set is an unordered and non-repetitive data combination, which has two main functions, namely, deduplication and relational testing.