python如何判断元素是否为for循环的最后一个元素
1个回答
展开全部
notices = ["Another "] * len(elements)
notices[-1] = ""
for element, note in zip(elements, notices):
print('Bug is in line '+element.attrib['start'])
print(note)
or
lastpos = len(elements) - 1
for i, element in enumerate(elements):
print('Bug is in line '+element.attrib['start'])
print("Another " and i < lastpos or "")
notices[-1] = ""
for element, note in zip(elements, notices):
print('Bug is in line '+element.attrib['start'])
print(note)
or
lastpos = len(elements) - 1
for i, element in enumerate(elements):
print('Bug is in line '+element.attrib['start'])
print("Another " and i < lastpos or "")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询