编程语言爱好者自然语言处理(NLP)Python教程专栏

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

2017-12-31  本文已影响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))


上一篇下一篇

猜你喜欢

热点阅读