It is tempting to use the [] operator on the left side of an assignment, with the intention of changing a character in a string.

The ‘object’ in this case is the string and the ‘item’ is the character tried to assign. For now, an object is the same thing as a value, but we will refine that definition later. An item is one of the values in a sequence. The reason for the error is that strings are immutable, which means you can’t change an existing string. The best you can do is create a new string that is a variation on the original:

This example concatenates a new first letter onto a slice of greeting. It has no effect on the original string.

from Thinking in Python

Strings are immutable的更多相关文章

  1. Core Java Volume I — 3.6. Strings

    3.6. StringsConceptually, Java strings are sequences of Unicode characters(Java的字符串是一个Unicode序列). Fo ...

  2. Think Python - Chapter 8 - Strings

    8.1 A string is a sequenceA string is a sequence of characters. You can access the characters one at ...

  3. C# Best Practices - Handling Strings

    Features Strings Are Immutable. A String Is a Reference Type Value Type Store their data directly Ex ...

  4. 论immutable不可变性

    什么叫immutable和mutable?简单来讲,一个immutable的对象一旦被创建好,它的状态将不会改变.反过来,如果一个类的实例是immutable的,那么我们把这个类也称作immutabl ...

  5. Why are C# structs immutable?

    Compiler Error CS1612 Cannot modify the return value of 'expression' because it is not a variable cl ...

  6. Unity 最佳实践

    转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...

  7. Java学习笔记1

    学习一个Coursera的Data-structures-optimizing-performance. Working with String in Java Flesh score Flesh s ...

  8. java标准-密码用数组比用字符串安全

    转载:http://my.oschina.net/jasonultimate/blog/166968 1) Since Strings are immutable in Java if you sto ...

  9. Microsoft Win32 to Microsoft .NET Framework API Map

    Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles   ...

随机推荐

  1. Android之怎样改变焦点状态【EditText】

    以EditText为例 1.改变焦点状态 password.setOnFocusChangeListener(new OnFocusChangeListener() { @Override publi ...

  2. CoreData 从入门到精通(四)并发操作

    通常情况下,CoreData 的增删改查操作都在主线程上执行,那么对数据库的操作就会影响到 UI 操作,这在操作的数据量比较小的时候,执行的速度很快,我们也不会察觉到对 UI 的影响,但是当数据量特别 ...

  3. zzuoj--10399--Turing equation(模拟)

    Turing equation Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 152  Solved: 85 [Submit][Status][Web ...

  4. nyoj--138--找球号(二)(hash+邻接表)

    找球号(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:5 描述 在某一国度里流行着一种游戏.游戏规则为:现有一堆球中,每个球上都有一个整数编号i(0<=i<=1 ...

  5. java算法数据结构

    原文地址:github.com/kdn251/interviews 译文出自:掘金翻译计划 译者:王下邀月熊 校对者:PhxNirvana.根号三 这个 链接 用来查看本翻译与英文版是否有差别(如果你 ...

  6. jqGrid多级表格的实现

    原博主链接:http://blog.csdn.net/dreamstar613/article/details/54616503 jqGrid多级表格(可N级) 主要用的方法: subGridRowE ...

  7. IDEA创建Maven项目显示一直加载中的问题

    使用IDEA这款工具创建Maven项目的时候出现过下面这种情况: 红色区域即maven骨架加载不出来... 或 loading loading loading ... 有时候需要很长一段时间才能加载出 ...

  8. confluence6.0.3安装文档

    一.Atlassian Confluence 6.0.3安装文档包含内容 1.wiki的安装步骤: 2.旧系统迁移中碰到的无法编辑和问题和解决方案: 3.wiki源码安装包.连接mysql用的jar包 ...

  9. linux 下的小知识

    Linux中有7种启动级别 运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆运行级别2:多用户状态(没有NFS ...

  10. MHA搭建及故障维护

    MHA是一种方便简单可靠的MySQL高可用架构,具体的介绍我在这里就不多说了,下面是我在网上找的一个教程,我在此基础上进行了一些修改: 大致步骤 (一).环境介绍 (二).用ssh-keygen实现四 ...