Data types for Python:
- Number (int, float, bool, complex)
- String
- List
- Tuple
- Set
- Dictionary
To view the data types type ():
In Python3, the integer type is only int, there is no long integer type, and we can see the data type of the variable or constant through type ().
We can clear the contents of the variables we declare by using the DEL keyword.
String strings:
strings are indexed (subscript) to locate each character in a string, the sequential index starts at 0, the reverse index starts at 1, the string is copied using *, and the string is spliced with +, but the data type must be the STR string type in the stitching process.
Escaping occurs when the "\" or "//" escape character is present in a string, where we can precede the string with an "R" to make the string output the original content (emphasizing that it cannot be changed after the string declaration in Python)
List of lists:
The list is written in brackets and the elements are separated by commas, such as List = [' Hello ', ' world ']
List lists can be stitched by + or copied via *
The elements of list lists are mutable
List lists can work with indexes, slices, and so on
function operations on list lists and string strings are explained in subsequent articles
Tuple Ganso:
The difference between the Ganso and the list is first in the format: list = [' Hello ', ' world '], tuple = (' element1 ', ' element2 '), and in addition to the list, the tuple element is immutable
Other property functions are consistent with string, but in a sense the string is a special Ganso, a subset of the Ganso
Set Set:
Set can use {} and set () to create a collection, but if you want to create an empty collection you must use Set (), because {} is the way to create an empty dictionary
Set can automatically remove duplicate elements and enter non-sequential outputs
Set can perform set operations
Dictionary dictionary:
A dictionary is a type of mapping, in the form of dictionary = {' key ': ' Value '}, which is an unordered key (key): A value pair collection, in which the key (key) must be unique, and {} is used when creating an empty dictionary.
Knowledge is iterative every day, the article is updated every day, Python test Development Exchange Group: 875120095 welcome you to join!
Python data type