001、
>>> test1 = ["a", "b", "c", "d", "e", "f", "g"] ## 测试列表 >>> test1 ['a', 'b', 'c', 'd', 'e', 'f', 'g'] >>> test1[2:-2] ## 同时删除首尾的两个字符 ['c', 'd', 'e'] >>> str1 = "abcdefg" ## 测试字符串 >>> str1 'abcdefg' >>> str1[2:-1] ## 删除字符串前两个字符、最后一个字符 'cdef' >>> tuple1 = (1, 2, 3, 4, 5, 6, 7) >>> tuple1[3:] (4, 5, 6, 7) >>> tuple1[2:-2] ## 应用于元组 (3, 4, 5)