如下代码
a=''
a[0]
运行之后会有如下报错提示
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a[0]
IndexError: string index out of range
但是如果我把代码改成这样,却能够正常运行
a=''
a[:1]
我想知道a[0]和a[:1]之间有什么区别,为什么上述代码a[0]不可以运行,而a[:1]却可以正常运行?