From 76633f876ac3a2b61847600dcb4fbd14a664b35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E8=B6=85=E6=81=92?= <296008606@qq.com> Date: Fri, 26 Jan 2018 14:16:40 +0800 Subject: [PATCH] =?UTF-8?q?!83=20=E6=AE=B5=E8=B6=85=E6=81=92=E7=AC=AC5?= =?UTF-8?q?=E5=A4=A9=E7=9A=84=E4=BD=9C=E4=B8=9A=20Merge=20pull=20request?= =?UTF-8?q?=20!83=20from=20=E6=AE=B5=E8=B6=85=E6=81=92/master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5_\346\256\265\350\266\205\346\201\222.py" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "\346\256\265\350\266\205\346\201\222/zy_05_\346\256\265\350\266\205\346\201\222.py" diff --git "a/\346\256\265\350\266\205\346\201\222/zy_05_\346\256\265\350\266\205\346\201\222.py" "b/\346\256\265\350\266\205\346\201\222/zy_05_\346\256\265\350\266\205\346\201\222.py" new file mode 100644 index 0000000..9d4ec76 --- /dev/null +++ "b/\346\256\265\350\266\205\346\201\222/zy_05_\346\256\265\350\266\205\346\201\222.py" @@ -0,0 +1,34 @@ +# coding:utf-8 +''' + @time: 18/1/24 +''' +# 1 +a_dict={"dog":3,"pig":5} +#添加 +a_dict["cat"]=4 +print(a_dict) +#删除 +a_dict.pop("cat") +print(a_dict) +#更新 +a_dict["pig"]=4 +print(a_dict) +#清空 +a_dict.clear() +print(a_dict) + +# 2 +num1_set ={1,2,4,6,3,8} +num2_set ={2,3,6,4,7} +num1=num1_set&num2_set +num2=num1_set|num2_set +num3=num1_set^num2_set +num4=num1_set-num2_set +print(num1,num2,num3,num4) + + +#3 +num_dict = {'a':13,'b':22,'c':18,'d':24} +i=sorted(num_dict.items(),key = lambda x:x[1],reverse = False) +print(dict(i)) + -- Gitee