我想检查一个值是否在列表中的另一个之前。我问了一会儿这个问题:TypeError: 'GitHubIterator' object does not support indexing,它允许我访问列表中的最后一条评论。我想展开此查看拉请求中的所有评论,看#hold-off
评论是否在#sign-off comment
之后。我可以使用print语句打印注释,但是它错误地查看错误消息的值的顺序:AttributeError: 'IssueComment' object has no attribute 'index'
。检查一个值是否在列表中的另一个之前
我想我需要以某种方式获得评论的主体列表,然后使用索引来确定顺序,因为迭代器不支持索引。但是我一直没有成功实现这个目标。
hold_off_regex_search_string = re.compile(r"\B#hold-off\b", re.IGNORECASE)
sign_off_regex_search_string = re.compile(r"\B#sign-off\b", re.IGNORECASE)
for comments in list(GitAuth.repo.issue(prs.number).comments()):
print (comments.body)
if comments.index(hold_off_regex_search_string.search(comments.body)) > comments.index(sign_off_regex_search_string.search(comments.body)):
print('True')
你不能只是做一个're.search(R '#拖延[\ W \ S] +#签收',comments.body)'这将返回匹配你的病情?我假设评论将以逗号分隔的单词。 –