|
发表于 2022-8-6 00:10:24
|
显示全部楼层
本楼为最佳答案
1. string index out of range,是指用index获取字符串中的字符时,index超出了它的最大长度。
2. invalid literal for int() with base 10: 'C', 是指给int传入了字符,int需要传输数字。
- >>> s = '1234'
- >>> s[3]
- '4'
- >>> s[4]
- Traceback (most recent call last):
- File "<pyshell#2>", line 1, in <module>
- s[4]
- IndexError: string index out of range
- >>>
- >>> int('C')
- Traceback (most recent call last):
- File "<pyshell#3>", line 1, in <module>
- int('C')
- ValueError: invalid literal for int() with base 10: 'C'
- >>>
复制代码 |
|