Python:元旦来临必须写的代码



# -------------------------------
# 节日祝福  Author:传习者戚
# Email: qijiuzhu@tsinghua.org.cn
# 2017-12-31
# Python3.5
# -------------------------------

# 定义祝福语
bast_wishes = lambda name: "祝" + name + \
                           "同学2018元旦快乐!新的一年心想事成!"

# 朋友信息资料
friends = dict(
    研三={"联系": "Yes", "人品": "A"},
    演艺={"联系": "Yes", "人品": "B"},
    清华={"联系": "Yes", "人品": "A"},
    酒肉={"联系": "Yes", "人品": "C"})

# 筛选拟发祝福的朋友
best_friends = [key for key, value in friends.items()
                if value["联系"] == "Yes" and value["人品"] == "A"]

# 分配并输出祝福语
information = list(map(bast_wishes, best_friends))
print("\n".join(info for info in information))


    原文作者:传习者戚
    原文地址: https://www.jianshu.com/p/288c2d18433a
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞