简单数据类型:1.步长的概念。2.字符串中的内容没有实际意义,只是表示的作用,所以不可变
>>> mystr = 'abcdefg' >>> mystr[0::1] 'abcdefg' >>> mystr[0::2] #步长计算从自已本身算起 'aceg' >>> mystr[0::-1]#从右往左 'a' >>> mystr[::-1] 'gfedcba' >>> mystr[0] = '1' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment #字符串中的内容没有实际意义,只是表示的作用,所以不可变 >>> mystr[0] = 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment
浙公网安备 33010602011771号