From 8ed8f0af48682f24bc190d93687682a663cca73f Mon Sep 17 00:00:00 2001 From: anyin233 Date: Mon, 15 Jun 2020 10:16:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AC=AC=E4=B8=80=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dict_use.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dict_use.py diff --git a/dict_use.py b/dict_use.py new file mode 100644 index 0000000..82e8da5 --- /dev/null +++ b/dict_use.py @@ -0,0 +1,15 @@ +import random + +words_list = ['sdf', 'asd', 'fds', 'zxc', 'fasd', 'wef', 'few', 'ewfd', 'gsg', 'fefs', 'fxce'] + +aList = [random.choice(words_list) for _ in range(1000)] + +b_dict = dict() + +for w in aList: + b_dict[w] = b_dict.get(w, 0) + 1 + +for k, v in b_dict.items(): + print("{}:{} times".format(k, v)) + +