简体   繁体   English

python 中的可变类型

[英]Mutable types in python

Of the basic types of python, which of those are mutable?在 python 的基本类型中,哪些是可变的? From reviewing the docs it looks like:通过查看文档,它看起来像:

  • list
  • set (though not frozenset ) set (虽然不是frozenset
  • dict

Are the only mutable types, and everything else is immutable, but I wasn't able to find a definitive list on this.是唯一可变的类型,其他一切都是不可变的,但我无法找到关于此的明确列表。 Is the above correct, or am I missing any python types that are mutable?以上是否正确,或者我是否遗漏了任何可变的 python 类型?

Take a look to this page in documentation .查看文档中的此页面 Here you can find all information about mutability of most common types in Python.在这里,您可以在 Python 中找到有关最常见类型可变性的所有信息。

PS It is rather comment than answer, but my reputation is too small to comment. PS 与其说是回答,不如说是评论,但我的声望太小,无法评论。

  1. Some of the mutable data types in Python are list, dictionary, set and user-defined classes. Python 中的一些可变数据类型是列表、字典、集合和用户定义的类。

  2. On the other hand, some of the immutable data types are int, float, decimal, bool, string, tuple, and range.另一方面,一些不可变数据类型是 int、float、decimal、bool、string、tuple 和 range。

https://towardsdatascience.com/https-towardsdatascience-com-python-basics-mutable-vs-immutable-objects-829a0cb1530a[Source][1] https://towardsdatascience.com/https-towardsdatascience-com-python-basics-mutable-vs-immutable-objects-829a0cb1530a[来源][1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM