标签:python 取出 整数 format indexer try put 输入格式 erro
输入一行字符串及下标,能取出相应字符。程序能对不合法数据做相应异常处理。
下标要整数下标越界python
1
y
python
a
下标要整数
python
10
下标越界
try:
s = input()
x = input()
print("{}".format(s[int(x)]))
except ValueError:
print("下标要整数")
except IndexError:
print("下标越界")
7-43 jmu-python-字符串异常处理 (20 分)
标签:python 取出 整数 format indexer try put 输入格式 erro
原文地址:https://www.cnblogs.com/aimilu/p/11819151.html