python,文件有些代码不明白,求解释。
python3吧
全部回复
仅看楼主
level 2
def testTry(index,flag=False):
stulst = ['john','jenny','tom']
if flag:
try:
astu = stulst[index] #这句是怎么理解的,stulst 是一个列表吧,列表有这种写法吗。困惑
except IndexError:
print('indexerror:列表越界引发的异常')
return 'try test fininshed!'
else:
astu = stulst[index]
return 'no try'
2020年11月03日 01点11分 1
1