eurovision.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:eurovision-country-selector 作者: mikejarrett 项目源码 文件源码
def write_data_to_csv(csv_name, people, countries):
    """ Loop through the list of people and write them to a csv.

    Args:
        csv_name (str): Name of the file to write results to.
        people (list): List of instantiated ``Person`` objects.
        countries (list): List of strings that represent countries.
    """
    with open(csv_name, 'w') as outfile:
        writer = csv.writer(outfile)
        columns = ['name'] + countries
        writer.writerow(columns)
        for person in people:
            person_row = [person.name] + [
                getattr(person, country, 0) for country in countries
            ]
            writer.writerow(person_row)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号