【发布时间】:2018-04-17 11:13:51
【问题描述】:
我正在尝试在 for 循环中获取子字符串。为此,我正在使用这个:
for peoject in subjects:
peoject_name = peoject.content
print(peoject_name, " : ", len(peoject_name), " : ", len(peoject_name.split('-')[1]))
我有一些项目在句子中没有任何“-”。我该如何处理?
我遇到了这个问题:
builtins.IndexError: list index out of range
【问题讨论】:
标签: python split outofrangeexception