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

作者: 传习者戚 | 来源:发表于2017-12-31 11:50 被阅读22次


# -------------------------------
# 节日祝福  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))


相关文章

网友评论

    本文标题:Python:元旦来临必须写的代码

    本文链接:https://www.haomeiwen.com/subject/shwogxtx.html