Python的str是不能修改的,但是我们可以通过切片操作来变相的实现插入 删除和修改等操作。
lonfee@ubuntu:~$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a='0034' >>> a[1]='1' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment >>> a=a[:1]+'1'+a[2:] >>> print a 0134 >>> a=a[:2]+'2'+a[2:] >>> print a 01234 >>>