Home >Backend Development >Python Tutorial >What is the difference between tuples and lists in python

What is the difference between tuples and lists in python

王林
王林Original
2020-05-09 14:14:5918021browse

What is the difference between tuples and lists in python

The difference between tuples and lists in python is as follows:

1. Lists are dynamic arrays. They are immutable and can reset their length (change the number of their internal elements). Number);

2. Tuples are static arrays, they are immutable, and their internal data cannot be changed once created;

3. Tuples are cached in the Python runtime environment, which means This means we don't need to access the kernel to allocate memory every time we use a tuple.

Recommended tutorial: python tutorial

The above is the detailed content of What is the difference between tuples and lists in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn