1.字符串
1.1不同于 C 字符串,Python 字符串不可变。向字符串文本的某一个索引赋值会引发错误:
>>> word[0] = 'x'
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'str' object does not support item assignment
>>> word[:1] = 'Splat'
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'str' object does not support slice assignment
1.2 支持word[2,4], word[-4,-2]格式,负数是从右向左数的。而且,负索引切片越界会被截......
阅读全文