例1
a = ['a', 'b', 'c', 'd', 'e', 'f']
b = '{1+2-3*4(5/6)7}'
print('a[::2]:',type(a[::2]), a[::2])
print('b[::2]:', type(b[::2]), b[::2])
输出:
a[::2]: <class 'list'> ['a', 'c', 'e']
b[::2]: <class 'str'> {+-*(/)}
例2
a = ['a', 'b', 'c', 'd', 'e', 'f']
b = '{1+2-3*4(5/6)7}'
print('a[1::2]:',type(a[1::2]), a[1::2])
print('b[1::2]:', type(b[1::2]), b[1::2])
输出:
a[1::2]: <class 'list'> ['b', 'd', 'f']
b[1::2]: <class 'str'> 1234567