gpt4 book ai didi

python - 精简功能

转载 作者:太空宇宙 更新时间:2023-11-04 09:09:44 26 4
gpt4 key购买 nike

<分区>

我已经使用这个程序有一段时间了,坚持下去似乎很乏味,但为了练习目的,我针对 pylint 运行我的代码,但我收到错误 R0912: 69,0:process_ancestors:分支太多(7/6)。我想知道是否有人能够帮助我精简此功能,因为它对我来说似乎是最简单的形式..

def process_ancestors(relation_dict, name):
'''Figures out who the ancestors are'''
output_str = ''
name_found = search_name(relation_dict, name)
if not name_found:
output_str = "Unknown person"
else:
ancestor_list = []
person = name
while True:
person = find_parent(relation_dict, person)
if person == None:
break
else:
ancestor_list.append(person)
if ancestor_list:
output_str = ", ".join(ancestor_list)
else:
output_str = "No known ancestors"

return output_str

为您的帮助干杯!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com