Why are Python strings immutable? 字符串是否可以改变
Posted papering
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Why are Python strings immutable? 字符串是否可以改变相关的知识,希望对你有一定的参考价值。
实践
1、
python
golang
// UnassignableOperand occurs when the left-hand side of an assignment is
// not assignable.
//
// Example:
// func f()
// const c = 1
// c = 2
//
UnassignableOperand
Design and History FAQ — Python 3.11.3 documentation https://docs.python.org/3/faq/design.html#why-are-python-strings-immutable
为什么Python字符串是不可变的?
有几个优点。
一个是性能:知道字符串是不可变的,意味着我们可以在创建时为它分配空间,并且存储需求是固定不变的。这也是元组和列表之间区别的原因之一。
另一个优点是,Python 中的字符串被视为与数字一样“基本”。 任何动作都不会将值 8 更改为其他值,在 Python 中,任何动作都不会将字符串 "8" 更改为其他值。
Why are Python strings immutable?
There are several advantages.
One is performance: knowing that a string is immutable means we can allocate space for it at creation time, and the storage requirements are fixed and unchanging. This is also one of the reasons for the distinction between tuples and lists.
Another advantage is that strings in Python are considered as “elemental” as numbers. No amount of activity will change the value 8 to anything else, and in Python, no amount of activity will change the string “eight” to anything else.
翻译
搜索
复制
Why are managers important?
The first reason managers are important is that organizations need their managerial skills and abilities more than ever in these uncertain,complex,and chaotic times.
Another reason managers are important to organizations is that they‘re critical to getting things done.
Finally, Managers do matter to organizations. Because the single most important variable in employee productivity and loyalty isn‘t pay or benefits or workplace environment;it‘s the quality of the relationship between employees and the direct supervisors.
以上是关于Why are Python strings immutable? 字符串是否可以改变的主要内容,如果未能解决你的问题,请参考以下文章
Why Web Services are needed in Industry
Why Web Services are needed in Industry
Why failover-based implementations are not enough
Why failover-based implementations are not enough