From b74842a24795c82f125e26440e7de7c9293fb3d9 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Mon, 21 Dec 2020 23:18:08 +0800 Subject: [PATCH 01/25] week class3 --- ...50\347\254\254\344\270\211\350\257\276.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" new file mode 100644 index 00000000..c90c7ba7 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -0,0 +1,19 @@ +aa = True +bb = b'hello world!' +cc = None + +a = [3, 3.14, 'hello world', aa, bb, cc] +b = (3, 3.14, 'hello world', aa, bb, cc) +c = { + "a01":3, + "a02":3.14, + "a03":'hello world', + "a04":aa, + "a05":bb, + "a06":cc, +} +d = {3, 3.14, 'hello world', aa, bb, cc} +print(a) +print(b) +print(c) +print(d) -- Gitee From 71bda5c92292fa4f6605fb7c9b031e2b9a211641 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 23 Dec 2020 20:10:28 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\270\200\350\257\276.py" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" new file mode 100644 index 00000000..44f74e8b --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -0,0 +1,53 @@ + +#加法运算 +def add(a, b): + c = a+b + return c + +result = add(2, 5) +print(result) + + +#减法运算 +def sub(a, b): + c = a-b + return c + +result=sub(8, 5) +print(result) + + +#乘法运算 +def mul(a, b): + c = a*b + return c + +result=mul(2, 3) +print(result) + + +#除法运算 +def div(a, b): + c = a/b + return c + +result=div(8, 2) +print(result) + + +#取余运算 +def rem(a, b): + c = a%b + return c + +result=rem(7, 3) +print(result) + + +#开方运算 +def pre(a): + c = a**(1/2) + return c + +result=pre(9) +print(result) -- Gitee From 65b50196a968cd773563e203a04b675a6cb1cda6 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 23 Dec 2020 20:35:09 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\270\200\350\257\276.py" | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" index 44f74e8b..815c3c74 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -1,7 +1,7 @@ #加法运算 def add(a, b): - c = a+b + c = a + b return c result = add(2, 5) @@ -10,44 +10,44 @@ print(result) #减法运算 def sub(a, b): - c = a-b + c = a - b return c -result=sub(8, 5) +result = sub(8, 5) print(result) #乘法运算 def mul(a, b): - c = a*b + c = a * b return c -result=mul(2, 3) +result = mul(2, 3) print(result) #除法运算 def div(a, b): - c = a/b + c = a / b return c -result=div(8, 2) +result = div(8, 2) print(result) #取余运算 def rem(a, b): - c = a%b + c = a % b return c -result=rem(7, 3) +result = rem(7, 3) print(result) #开方运算 def pre(a): - c = a**(1/2) + c = a ** (1/2) return c -result=pre(9) +result = pre(9) print(result) -- Gitee From 76731aa7312692dff853595c2e1ba03a77d071fe Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Fri, 25 Dec 2020 22:01:49 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\272\214\350\257\276.py" | 82 +++++++++++++++++++ ...0\347\254\254\344\272\214\350\257\276.txt" | 78 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" new file mode 100644 index 00000000..2ed404cc --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" @@ -0,0 +1,82 @@ +output = open("第二周第二课.txt", "w", encoding="utf-8") +content = """ + +#字符串的编码和解码 +>>> a = "我爱python" +>>> a.encode("utf-8") +b'\xe6\x88\x91\xe7\x88\xb1python' +>>> b = a.encode("utf-8") +>>> b.decode("utf-8") +'我爱python' + + +#字符串的CRUD操作 +#1、创建(create) +>>> a = "hello" +>>> a = a + "world" +>>> a +'helloworld' + + +>>> a = "hello" +>>> a += "world" +>>> a +'helloworld' + + +#2、检索 +>>> a = "I love python" +>>> a[3] +'o' +>>> a.find("o") +3 + +>>> a = "12345.*****" +>>> a.startswith("12345") +True +>>> b = "*****_python" +>>> b.endswith("python") +True + +#3、更新(update) +>>> a = "I love pythen" +>>> a.replace("en", "on") +'I love python' + +>>> b = "apple, pear, banana, orange" +>>> b.split(",") +['apple', ' pear', ' banana', ' orange'] + +>>> c = b.split(",") +>>> ",".join(c) +'apple, pear, banana, orange' + +#4、删除 +>>> d = " I love python " +>>> d.strip() +'I love python' +>>> d.lstrip() +'I love python ' +>>> d.rstrip() +' I love python' + + +#字符串的格式化输出 +>>> a = "I" +>>> b = "love" +>>> c = "python" +>>> "{} {} {}".format(a, b, c) +'I love python' +>>> "{a} {b} {c}".format(a = "I", b = "love", c = "python") +'I love python' +>>> print(f"{a} {b} {c}") +I love python + +>>> a = 2.71828 +>>> "{:.3f}".format(a) +'2.718' + + +""" +output.write(content) +output.close() \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" new file mode 100644 index 00000000..31ce5d9b --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" @@ -0,0 +1,78 @@ + + +#字符串的编码和解码 +>>> a = "我爱python" +>>> a.encode("utf-8") +b'我爱python' +>>> b = a.encode("utf-8") +>>> b.decode("utf-8") +'我爱python' + + +#字符串的CRUD操作 +#1、创建(create) +>>> a = "hello" +>>> a = a + "world" +>>> a +'helloworld' + + +>>> a = "hello" +>>> a += "world" +>>> a +'helloworld' + + +#2、检索 +>>> a = "I love python" +>>> a[3] +'o' +>>> a.find("o") +3 + +>>> a = "12345.*****" +>>> a.startswith("12345") +True +>>> b = "*****_python" +>>> b.endswith("python") +True + +#3、更新(update) +>>> a = "I love pythen" +>>> a.replace("en", "on") +'I love python' + +>>> b = "apple, pear, banana, orange" +>>> b.split(",") +['apple', ' pear', ' banana', ' orange'] + +>>> c = b.split(",") +>>> ",".join(c) +'apple, pear, banana, orange' + +#4、删除 +>>> d = " I love python " +>>> d.strip() +'I love python' +>>> d.lstrip() +'I love python ' +>>> d.rstrip() +' I love python' + + +#字符串的格式化输出 +>>> a = "I" +>>> b = "love" +>>> c = "python" +>>> "{} {} {}".format(a, b, c) +'I love python' +>>> "{a} {b} {c}".format(a = "I", b = "love", c = "python") +'I love python' +>>> print(f"{a} {b} {c}") +I love python + +>>> a = 2.71828 +>>> "{:.3f}".format(a) +'2.718' + + -- Gitee From ef56e637f83afe75a7480c729f910115a5008350 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 27 Dec 2020 22:13:15 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\270\211\350\257\276.py" | 164 ++++++++++++++++++ ...0\347\254\254\344\270\211\350\257\276.txt" | 160 +++++++++++++++++ ...50\347\254\254\344\272\214\350\257\276.py" | 2 +- 3 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" new file mode 100644 index 00000000..4911b1e8 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -0,0 +1,164 @@ +output = open("第二周第三课.txt", "w", encoding="utf-8") +content = """ + + +#append(末尾添加元素) +>>> list_1 = ['a', 'b',] +>>> list_1.append('c') +>>> list_1 +['a', 'b', 'c'] + +#+和+= +>>> list_1 = ['a', 'b'] +>>> list_2 = ['c'] +>>> list_1 = list_1 + list_2 +>>> list_1 +['a', 'b', 'c'] + +>>> list_3 = ['ff'] +>>> list_1 += list_3 +>>> list_1 +['a', 'b', 'c', 'ff'] + +#*和*= +>>> list_1 = ['cc'] +>>> list_1 = list_1 * 10 +>>> list_1 +['cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc'] +>>> list_2 = ['dd'] +>>> list_2 *= 10 +>>> list_2 +['dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd'] + +#insert指定位置添加元素 +>>> list_1 = ['1', '2', '3'] +>>> list_.insert(1,'b') +>>> list_1 +['1', 'b', '2', '3'] + +#索引取值 +>>> list_1 = ['1', '2', '3'] +>>> list_1[2] +'3' + +#切片 +>>>list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] +>>> list_1[0:10:2] +[1, 3, 5, 7, 9] +>>> list_1[-1] +20 +>>> list_1.index(1) +0 + +#update +>>> list_1 = ['a', 'b', 'c', 'd', 'e', 'f'] +>>> list_1[1] = '00' +>>> list_1 +['a', '00', 'c', 'd', 'e', 'f'] +>>> list_1[1:3] = "45" +>>> list_1 +['a', '4', '5', 'd', 'e', 'f'] + +#delete +>>> list_1 = ['1', '2', '3'] +>>> list_1.pop() +'3' +>>> list_1.clear() +>>> list_1 +[] + +#排序 +>>> list_1 = [1, 2, 3, 4, 5] +>>> list_1 = [5, 6, 1, 9, 10] +>>> list_1.sort() +>>> list_1 +[1, 5, 6, 9, 10] + +list_2 = [5, 6, 1, 9, 10] +>>> sorted(list_2) +[1, 5, 6, 9, 10] + +>>> list_1 = [2, 6, 8, 4, 1] +>>> list_2 = [5, 9, 3, 7] +>>> list_1.reverse() +>>> list_1 +[1, 4, 8, 6, 2] + + +#tuple +>>> tuple_1 = ('a', 'b', 'c', 'd') +>>> tuple_1[0] +'a' +>>> tuple_1.index('c') +2 +>>> tuple_1[0:2] +('a', 'b') + + +#dict +>>> dict_1 = {'a': 1, 'b': 2, 'c': 3} +>>> dict_1['d'] = 4 +>>> dict_1 +{'a': 1, 'b': 2, 'c': 3, 'd': 4} +>>> dict_2 = {'e': 5} +>>> dict_1.update(dict_2) +>>> dict_1 +{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5} +>>> dict_1.setdefault('d', 8) +4 +>>> dict_1.setdefault('f', 6) +6 +>>> dict_1['b'] +2 +>>> dict_1.get('g', 7) +7 +>>> dict_1.keys() +dict_keys(['a', 'b', 'c', 'd', 'e', 'f']) +>>> dict_1.values() +dict_values([1, 2, 3, 4, 5, 6]) +>>> dict_1.items() +dict_items([('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6)]) +>>> dict_1['b'] = 24 +>>> dict_1 +{'a': 1, 'b': 24, 'c': 3, 'd': 4, 'e': 5, 'f': 6} +>>> dict_1.update({'h': 10}) +>>> dict_1 +{'a': 1, 'b': 24, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'h': 10} +>>> dict_1.pop('c') +3 +>>> dict_1.popitem() +('h', 10) + + +#set +>>> set_1 = set([1, 2, 3]) +>>> set_1.add(4) +>>> set_1 +{1, 2, 3, 4} +>>> 2 in set_1 +True +>>> set_2 = set([5, 6]) +>>> set_1.update(set_2) +>>> set_1 +{1, 2, 3, 4, 5, 6} +>>> set_3 = set([7]) +>>> set_1.union(set_3) +{1, 2, 3, 4, 5, 6, 7} +>>> set_1.discard(3) +>>> set_1 +{1, 2, 4, 5, 6} +>>> set_1.remove(3) +Traceback (most recent call last): + File "", line 1, in +KeyError: 3 +>>> set_1.discard(3) +>>> + + + + + + +""" +output.write(content) +output.close() \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" new file mode 100644 index 00000000..f88794c3 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" @@ -0,0 +1,160 @@ + + + +#append(末尾添加元素) +>>> list_1 = ['a', 'b',] +>>> list_1.append('c') +>>> list_1 +['a', 'b', 'c'] + +#+和+= +>>> list_1 = ['a', 'b'] +>>> list_2 = ['c'] +>>> list_1 = list_1 + list_2 +>>> list_1 +['a', 'b', 'c'] + +>>> list_3 = ['ff'] +>>> list_1 += list_3 +>>> list_1 +['a', 'b', 'c', 'ff'] + +#*和*= +>>> list_1 = ['cc'] +>>> list_1 = list_1 * 10 +>>> list_1 +['cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc', 'cc'] +>>> list_2 = ['dd'] +>>> list_2 *= 10 +>>> list_2 +['dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd', 'dd'] + +#insert指定位置添加元素 +>>> list_1 = ['1', '2', '3'] +>>> list_.insert(1,'b') +>>> list_1 +['1', 'b', '2', '3'] + +#索引取值 +>>> list_1 = ['1', '2', '3'] +>>> list_1[2] +'3' + +#切片 +>>>list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] +>>> list_1[0:10:2] +[1, 3, 5, 7, 9] +>>> list_1[-1] +20 +>>> list_1.index(1) +0 + +#update +>>> list_1 = ['a', 'b', 'c', 'd', 'e', 'f'] +>>> list_1[1] = '00' +>>> list_1 +['a', '00', 'c', 'd', 'e', 'f'] +>>> list_1[1:3] = "45" +>>> list_1 +['a', '4', '5', 'd', 'e', 'f'] + +#delete +>>> list_1 = ['1', '2', '3'] +>>> list_1.pop() +'3' +>>> list_1.clear() +>>> list_1 +[] + +#排序 +>>> list_1 = [1, 2, 3, 4, 5] +>>> list_1 = [5, 6, 1, 9, 10] +>>> list_1.sort() +>>> list_1 +[1, 5, 6, 9, 10] + +list_2 = [5, 6, 1, 9, 10] +>>> sorted(list_2) +[1, 5, 6, 9, 10] + +>>> list_1 = [2, 6, 8, 4, 1] +>>> list_2 = [5, 9, 3, 7] +>>> list_1.reverse() +>>> list_1 +[1, 4, 8, 6, 2] + + +#tuple +>>> tuple_1 = ('a', 'b', 'c', 'd') +>>> tuple_1[0] +'a' +>>> tuple_1.index('c') +2 +>>> tuple_1[0:2] +('a', 'b') + + +#dict +>>> dict_1 = {'a': 1, 'b': 2, 'c': 3} +>>> dict_1['d'] = 4 +>>> dict_1 +{'a': 1, 'b': 2, 'c': 3, 'd': 4} +>>> dict_2 = {'e': 5} +>>> dict_1.update(dict_2) +>>> dict_1 +{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5} +>>> dict_1.setdefault('d', 8) +4 +>>> dict_1.setdefault('f', 6) +6 +>>> dict_1['b'] +2 +>>> dict_1.get('g', 7) +7 +>>> dict_1.keys() +dict_keys(['a', 'b', 'c', 'd', 'e', 'f']) +>>> dict_1.values() +dict_values([1, 2, 3, 4, 5, 6]) +>>> dict_1.items() +dict_items([('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6)]) +>>> dict_1['b'] = 24 +>>> dict_1 +{'a': 1, 'b': 24, 'c': 3, 'd': 4, 'e': 5, 'f': 6} +>>> dict_1.update({'h': 10}) +>>> dict_1 +{'a': 1, 'b': 24, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'h': 10} +>>> dict_1.pop('c') +3 +>>> dict_1.popitem() +('h', 10) + + +#set +>>> set_1 = set([1, 2, 3]) +>>> set_1.add(4) +>>> set_1 +{1, 2, 3, 4} +>>> 2 in set_1 +True +>>> set_2 = set([5, 6]) +>>> set_1.update(set_2) +>>> set_1 +{1, 2, 3, 4, 5, 6} +>>> set_3 = set([7]) +>>> set_1.union(set_3) +{1, 2, 3, 4, 5, 6, 7} +>>> set_1.discard(3) +>>> set_1 +{1, 2, 4, 5, 6} +>>> set_1.remove(3) +Traceback (most recent call last): + File "", line 1, in +KeyError: 3 +>>> set_1.discard(3) +>>> + + + + + + diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" index 2ed404cc..d23ff26d 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" @@ -79,4 +79,4 @@ I love python """ output.write(content) -output.close() \ No newline at end of file +output.close() -- Gitee From f99f8dadbc13a401549f935d9816a45286adaccd Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 27 Dec 2020 22:46:57 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...72\214\345\221\250\347\254\254\344\270\211\350\257\276.py" | 4 ---- 1 file changed, 4 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" index 4911b1e8..89eb85bc 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -155,10 +155,6 @@ KeyError: 3 >>> - - - - """ output.write(content) output.close() \ No newline at end of file -- Gitee From 8c49c3902143c02a01d99fb360b8d28cf7569621 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 27 Dec 2020 22:50:57 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\214\345\221\250\347\254\254\344\270\211\350\257\276.py" | 1 - ...\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" | 5 ----- 2 files changed, 6 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" index 89eb85bc..0ef7f37e 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -152,7 +152,6 @@ Traceback (most recent call last): File "", line 1, in KeyError: 3 >>> set_1.discard(3) ->>> """ diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" index f88794c3..fe4ee300 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" @@ -151,10 +151,5 @@ Traceback (most recent call last): File "", line 1, in KeyError: 3 >>> set_1.discard(3) ->>> - - - - -- Gitee From bfc0dd5a79721078f0b53b5e22498e97bcbce074 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 27 Dec 2020 22:52:32 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" | 2 +- ...272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" index 0ef7f37e..a4b21db3 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -152,7 +152,7 @@ Traceback (most recent call last): File "", line 1, in KeyError: 3 >>> set_1.discard(3) - +>>> """ output.write(content) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" index fe4ee300..e59f8578 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" @@ -151,5 +151,5 @@ Traceback (most recent call last): File "", line 1, in KeyError: 3 >>> set_1.discard(3) - +>>> -- Gitee From d9c0d32f1eb70511e6a7daccc3475fd8730efba8 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 27 Dec 2020 22:57:23 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" | 2 ++ ...272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" | 2 ++ 2 files changed, 4 insertions(+) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" index a4b21db3..a471612f 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -154,6 +154,8 @@ KeyError: 3 >>> set_1.discard(3) >>> + + """ output.write(content) output.close() \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" index e59f8578..56e1d977 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" @@ -153,3 +153,5 @@ KeyError: 3 >>> set_1.discard(3) >>> + + -- Gitee From cb1ec069d9cecea98f32891a639bc5649fa8ccad Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 30 Dec 2020 22:43:38 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\270\200\350\257\276.py" | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" new file mode 100644 index 00000000..f0e1233c --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -0,0 +1,82 @@ +#痴海第二期python训练营 +#2班--wong +#第三周第一课作业 + +#作业一、用for循环和while循环实现计数 + +print("用for循环实现计数x次") +a = input('请输入计数次数:') +a = int(a) +for i in range(a): + print(i) + +print('------------------------') + + +print("用while循环实现计数x次") +a = input('请输入计数次数:') +a = int(a) +i = 0 +while i < a: + print(i) + i += 1 + +print('------------------------') + + + +#作业二、分别用for循环和while循环实现斐波那切数列,限制在100以内 + +print("用for循环实现菲波那切数列") +a = 0 #设定第一项 +b = 1 #设定第二项 +print("斐波那契数列第 1 项:" ,a) #输出第一项 +print("斐波那契数列第 2 项:" ,b) #输出第二项 +i = 3 #计数从第3项开始 +for i in range(3,1000): + c = a + b + if c >= 100: + break + print("斐波那契数列第",i,"项:", c) + a = b + b = c + +print('------------------------') + + +print("用while循环实现菲波那切数列") +a = 0 +b = 1 +print("斐波那契数列第 1 项:" ,a) #输出第一项 +print("斐波那契数列第 2 项:" ,b) #输出第二项 +i = 3 #计数从第3项开始 +while i < 1000: + c = a + b + if c >= 100: + break + print("斐波那契数列第", i, "项:", c) + a = b + b = c + i += 1 + +print('------------------------') + + + +#作业三、对计算器参数进行检查,如果报错抛出自定义异常(以取余为例) +class ParamsError(Exception): + pass + +def rem(a, b): + if b == 0: + raise ParamsError("除数不能为0,请重新输入!") + c = a % b + return c + +a = int(input("请输入被除数:")) +b = int(input("请输入除数:")) +rem(a, b) + +result = rem(7, 3) +print(result) + -- Gitee From 6a7b85afb951839ded742bbbbf83094db5aca107 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Fri, 1 Jan 2021 20:33:09 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2\347\217\255/2\347\217\255_Wong/000.py" | 6 +++ ...50\347\254\254\344\270\200\350\257\276.py" | 37 +++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" new file mode 100644 index 00000000..f3a48836 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" @@ -0,0 +1,6 @@ +sum = 0 +i = 1 +while i<100: + sum += i + i += 2 +print(sum) \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" index f0e1233c..67a45222 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -4,22 +4,22 @@ #作业一、用for循环和while循环实现计数 -print("用for循环实现计数x次") -a = input('请输入计数次数:') -a = int(a) -for i in range(a): - print(i) +print("计算100以内偶数的和") +sum = 0 +for i in range(2, 101, 2): + sum += i +print(sum) print('------------------------') -print("用while循环实现计数x次") -a = input('请输入计数次数:') -a = int(a) -i = 0 -while i < a: - print(i) - i += 1 +print("计算100以内奇数的和") +sum = 0 +i = 1 +while i < 100: + sum += i + i += 2 +print(sum) print('------------------------') @@ -33,7 +33,7 @@ b = 1 #设定第二项 print("斐波那契数列第 1 项:" ,a) #输出第一项 print("斐波那契数列第 2 项:" ,b) #输出第二项 i = 3 #计数从第3项开始 -for i in range(3,1000): +for i in range(3, 1000): c = a + b if c >= 100: break @@ -68,15 +68,14 @@ class ParamsError(Exception): pass def rem(a, b): - if b == 0: + try: + c = a % b + return c + except ZeroDivisionError: raise ParamsError("除数不能为0,请重新输入!") - c = a % b - return c a = int(input("请输入被除数:")) b = int(input("请输入除数:")) -rem(a, b) - -result = rem(7, 3) +result = rem(a, b) print(result) -- Gitee From faecdd2da1237af199d5c7a54324b2ca223547f6 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Fri, 1 Jan 2021 20:34:13 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=9C=9F=E8=AE=AD=E7=BB=83=E8=90=A5/2?= =?UTF-8?q?=E7=8F=AD/2=E7=8F=AD=5FWong/000.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2\347\217\255/2\347\217\255_Wong/000.py" | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" deleted file mode 100644 index f3a48836..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/000.py" +++ /dev/null @@ -1,6 +0,0 @@ -sum = 0 -i = 1 -while i<100: - sum += i - i += 2 -print(sum) \ No newline at end of file -- Gitee From 0b6d9b965e3daccfd9c1621569e6f73000111559 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Fri, 1 Jan 2021 20:48:34 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\211\345\221\250\347\254\254\344\270\200\350\257\276.py" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" index 67a45222..e6996fe4 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -27,7 +27,7 @@ print('------------------------') #作业二、分别用for循环和while循环实现斐波那切数列,限制在100以内 -print("用for循环实现菲波那切数列") +print("用for循环实现斐波那契数列") a = 0 #设定第一项 b = 1 #设定第二项 print("斐波那契数列第 1 项:" ,a) #输出第一项 @@ -44,7 +44,7 @@ for i in range(3, 1000): print('------------------------') -print("用while循环实现菲波那切数列") +print("用while循环实现斐波那契数列") a = 0 b = 1 print("斐波那契数列第 1 项:" ,a) #输出第一项 -- Gitee From f5868028b214e4f3f27b9a4d5e6fd7d9badf66e0 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 3 Jan 2021 18:37:24 +0800 Subject: [PATCH 14/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" | 1 + 1 file changed, 1 insertion(+) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" index e6996fe4..4ddbed65 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -44,6 +44,7 @@ for i in range(3, 1000): print('------------------------') + print("用while循环实现斐波那契数列") a = 0 b = 1 -- Gitee From 1aa750dfd4c51742daab92869ae4de5e947d7f20 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 3 Jan 2021 22:04:00 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\272\214\350\257\276.py" | 41 +++++++++++++++++++ ...50\347\254\254\344\272\214\350\257\276.py" | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" new file mode 100644 index 00000000..c34a40f7 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" @@ -0,0 +1,41 @@ +classes = [ + {"name": "n_1", "age": 24, "grade": "A"}, + {"name": "n_2", "age": 23, "grade": "B"}, + {"name": "n_3", "age": 28, "grade": "A"}, + {"name": "n_4", "age": 24, "grade": "A"}, + {"name": "n_5", "age": 25, "grade": "C"}, + {"name": "n_6", "age": 21, "grade": "D"}, + {"name": "n_7", "age": 27, "grade": "A"}, +] + +#作业一、根据grade对上述列表进行排序 +classes.sort(key=lambda x: x["grade"]) +print(classes) + +#作业二、通过filter语句来筛选出Grade为A的同学 +f = filter(lambda x: x['grade'] == 'A', classes) +f = list(f) +print(f) + + +#作业三、通过map函数将上述同学的age + 1(对原数据结构有影响, 尽量不要用lambda) +def add(a): + a["age"] += 1 + return a + +m = map(add, classes) +m = list(m) +print(m) + + +#作业四、使用递归函数重构斐波那契数列 +def foo(n): + if n == 1: + return 0 + elif n == 2: + return 1 + else: + return foo(n-1) + foo(n-2) + +for i in range(1, 10): + print(foo(i)) \ No newline at end of file diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" index af7ca82c..f48126ed 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" @@ -1,4 +1,4 @@ -output = open("第二周第二课.txt", "w", encoding="utf-8") +output = open("第二周第二课.txt", "w", encoding="utf-8") content = """ #字符串的编码和解码 -- Gitee From 7ca6a7bdeeb631866da95eb0cc6bdcaaaed3e95c Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Sun, 3 Jan 2021 22:06:38 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" | 2 ++ 1 file changed, 2 insertions(+) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" index c34a40f7..37691796 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" @@ -8,10 +8,12 @@ classes = [ {"name": "n_7", "age": 27, "grade": "A"}, ] + #作业一、根据grade对上述列表进行排序 classes.sort(key=lambda x: x["grade"]) print(classes) + #作业二、通过filter语句来筛选出Grade为A的同学 f = filter(lambda x: x['grade'] == 'A', classes) f = list(f) -- Gitee From 2233e46571d74da0ff1d4aeddd264fd5d858813d Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Mon, 4 Jan 2021 17:47:26 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\270\211\350\257\276.py" | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" new file mode 100644 index 00000000..11fc7b16 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -0,0 +1,70 @@ +#作业一、作用域之间的转换 +a = 10 + +def foo(): + global a #局部变脸转换成全局变量 + a = 11 + print(a) + +foo() +print(a) + + +def foo(): + total = 0 + count = 0 + + def foo_1(value): + nonlocal total, count #局部变量转换成自由变量 + total += value + count += 1 + return total / count + + return foo_1 + +my_avg = foo() +print(my_avg(5)) +print(my_avg(8)) + + +#作业二、使用装饰器输出函数执行时间 + +import time + +def foo(a, b): + count = 1 + while True: + if count > a ** b: + break + count += 1 + +def time_1(func, a, b): + start_time = time.time() + result = func(a, b) + end_time = time.time() + print(f"{func.__name__} execute time: {format(end_time - start_time, '.2f')} s") + return result + +result = time_1(foo, 10, 6) +print(result) + + + +#三、为斐波那契数列增加缓存 +def cache_deco(fun1): + cache = {} + + def wrapper(*args): + if args not in cache: + cache[args] = fun1(*args) + return cache[args] + + return wrapper + +@cache_deco +def f(n): + if n <= 1: + return 1 + return f(n - 1) + f(n - 2) + +print(f(10)) \ No newline at end of file -- Gitee From 411ed246c02b262e63d1e2e01f847aafe1ddcf43 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 6 Jan 2021 20:43:47 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50\347\254\254\344\270\211\350\257\276.py" | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" index 11fc7b16..57577447 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -31,6 +31,16 @@ print(my_avg(8)) import time +def clock_it_deco(func): + def wrapper(*args, **kwargs): + start_time = time.time() + result = func(*args, **kwargs) + end_time = time.time() + print(f"{func.__name__} execute time: {format(end_time - start_time, '.2f')} s") + return result + return wrapper + +@clock_it_deco def foo(a, b): count = 1 while True: @@ -38,27 +48,16 @@ def foo(a, b): break count += 1 -def time_1(func, a, b): - start_time = time.time() - result = func(a, b) - end_time = time.time() - print(f"{func.__name__} execute time: {format(end_time - start_time, '.2f')} s") - return result - -result = time_1(foo, 10, 6) -print(result) - +foo(10, 6) #三、为斐波那契数列增加缓存 def cache_deco(fun1): cache = {} - def wrapper(*args): if args not in cache: cache[args] = fun1(*args) return cache[args] - return wrapper @cache_deco @@ -67,4 +66,4 @@ def f(n): return 1 return f(n - 1) + f(n - 2) -print(f(10)) \ No newline at end of file +print(f(8)) -- Gitee From 127770ddcf4030987b89ef8fa1ee979b034fd0a9 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 6 Jan 2021 20:50:55 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\221\250\347\254\254\344\270\211\350\257\276.py" | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" index 57577447..67a6c751 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -52,12 +52,12 @@ foo(10, 6) #三、为斐波那契数列增加缓存 -def cache_deco(fun1): - cache = {} +def cache_deco(func): + a = {} def wrapper(*args): - if args not in cache: - cache[args] = fun1(*args) - return cache[args] + if args not in a: + result = func(*args) + return result return wrapper @cache_deco @@ -66,4 +66,4 @@ def f(n): return 1 return f(n - 1) + f(n - 2) -print(f(8)) +print(f(10)) -- Gitee From b18551c3cd17a1fb6f8796c446652d1f2a00117e Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 6 Jan 2021 23:14:42 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\347\275\256\346\210\252\345\233\276.png" | Bin ...6\345\217\262\345\233\236\346\273\232.png" | Bin ...5\345\210\260\347\240\201\344\272\221.png" | Bin ...50\347\254\254\344\270\211\350\257\276.py" | 0 ...d\342\200\235\346\210\252\345\233\276.png" | Bin ...2\346\213\237\347\216\257\345\242\203.png" | Bin ...50\347\254\254\344\270\200\350\257\276.py" | 0 ...50\347\254\254\344\270\211\350\257\276.py" | 2 +- ...0\347\254\254\344\270\211\350\257\276.txt" | 0 ...50\347\254\254\344\272\214\350\257\276.py" | 0 ...0\347\254\254\344\272\214\350\257\276.txt" | 0 ...50\347\254\254\344\270\200\350\257\276.py" | 0 ...50\347\254\254\344\270\211\350\257\276.py" | 0 ...50\347\254\254\344\272\214\350\257\276.py" | 0 ...50\347\254\254\344\270\200\350\257\276.py" | 36 ++++++++++++++++++ 15 files changed, 37 insertions(+), 1 deletion(-) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/python\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\210\252\345\233\276.png" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/python\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\210\252\345\233\276.png" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\345\216\206\345\217\262\345\233\236\346\273\232.png" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\345\216\206\345\217\262\345\233\236\346\273\232.png" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\345\220\214\346\255\245\345\210\260\347\240\201\344\272\221.png" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\345\220\214\346\255\245\345\210\260\347\240\201\344\272\221.png" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\350\277\220\350\241\214\350\276\223\345\207\272\342\200\234hello world\342\200\235\346\210\252\345\233\276.png" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\350\277\220\350\241\214\350\276\223\345\207\272\342\200\234hello world\342\200\235\346\210\252\345\233\276.png" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\351\205\215\347\275\256\350\231\232\346\213\237\347\216\257\345\242\203.png" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\351\205\215\347\275\256\350\231\232\346\213\237\347\216\257\345\242\203.png" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" (97%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" (100%) rename "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" => "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" (100%) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/python\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\210\252\345\233\276.png" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/python\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\210\252\345\233\276.png" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/python\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\210\252\345\233\276.png" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/python\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\210\252\345\233\276.png" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\345\216\206\345\217\262\345\233\236\346\273\232.png" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\345\216\206\345\217\262\345\233\236\346\273\232.png" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\345\216\206\345\217\262\345\233\236\346\273\232.png" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\345\216\206\345\217\262\345\233\236\346\273\232.png" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\345\220\214\346\255\245\345\210\260\347\240\201\344\272\221.png" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\345\220\214\346\255\245\345\210\260\347\240\201\344\272\221.png" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\345\220\214\346\255\245\345\210\260\347\240\201\344\272\221.png" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\345\220\214\346\255\245\345\210\260\347\240\201\344\272\221.png" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\347\254\254\344\270\200\345\221\250\347\254\254\344\270\211\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\350\277\220\350\241\214\350\276\223\345\207\272\342\200\234hello world\342\200\235\346\210\252\345\233\276.png" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\350\277\220\350\241\214\350\276\223\345\207\272\342\200\234hello world\342\200\235\346\210\252\345\233\276.png" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\350\277\220\350\241\214\350\276\223\345\207\272\342\200\234hello world\342\200\235\346\210\252\345\233\276.png" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\350\277\220\350\241\214\350\276\223\345\207\272\342\200\234hello world\342\200\235\346\210\252\345\233\276.png" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\351\205\215\347\275\256\350\231\232\346\213\237\347\216\257\345\242\203.png" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\351\205\215\347\275\256\350\231\232\346\213\237\347\216\257\345\242\203.png" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\351\205\215\347\275\256\350\231\232\346\213\237\347\216\257\345\242\203.png" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/\351\205\215\347\275\256\350\231\232\346\213\237\347\216\257\345\242\203.png" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\200\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" similarity index 97% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" index a471612f..9722bec9 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.py" @@ -1,4 +1,4 @@ -output = open("第二周第三课.txt", "w", encoding="utf-8") +output = open("第二周第三课.txt", "w", encoding="utf-8") content = """ diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\270\211\350\257\276.txt" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week02/\347\254\254\344\272\214\345\221\250\347\254\254\344\272\214\350\257\276.txt" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\200\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\270\211\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" similarity index 100% rename from "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" rename to "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week03/\347\254\254\344\270\211\345\221\250\347\254\254\344\272\214\350\257\276.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" new file mode 100644 index 00000000..8a05d296 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -0,0 +1,36 @@ +#作业一、三种时间模式的转换 +#1、datetime.datetime->str +import datetime +from datetime import timedelta +now = datetime.datetime.now(tz=None) #获取当前时间 +now = now.strftime("%Y-%m-%d %H:%M:%S") #时间格式转换 datetime.datetime->str +print(now) + +#2、str->datetime.datetime +now = datetime.datetime.strptime(now, "%Y-%m-%d %H:%M:%S") #时间格式转换 str->datetime.datetime +print(now.__repr__()) + +#3、datetime.datetime->timestamp +now_1 = datetime.datetime.now(tz=None) #获取当前时间 +now_1 = now_1.timestamp() #时间格式转换 datetime.datetime->timestamp +print(now_1) + +#4、timestamp->datetime.datetime +now_1 = datetime.datetime.fromtimestamp(now_1, tz=None) #时间格式转换 timestamp->datetime.datetime +print(now_1.__repr__()) + +#作业二、封装一个函数get_date(day_delta), 如果传入的是-1 , 输出就是字符串日期2020-01-02 + +def get_date(day_delta): + if day_delta == -1: + now_2 = datetime.datetime.now(tz=None) # 获取当前时间 + print("当前时间为:", now_2) + now_2 = now_2 + timedelta(days=-1) # 日期减1 + now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 + return now_2 + else: + return None + + +date = get_date(-1) +print("日期减1后时间为", date) \ No newline at end of file -- Gitee From 193584ac3d5c61b3675098e6533229e277428980 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Wed, 6 Jan 2021 23:15:41 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20week01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2\347\217\255/2\347\217\255_Wong/week01/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/.keep" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week01/.keep" new file mode 100644 index 00000000..e69de29b -- Gitee From 8fb92237683937e378f28e61b7e2db514a19d565 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Thu, 7 Jan 2021 20:26:52 +0800 Subject: [PATCH 22/25] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\250\347\254\254\344\270\200\350\257\276.py" | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" index 8a05d296..96f84e63 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -22,15 +22,13 @@ print(now_1.__repr__()) #作业二、封装一个函数get_date(day_delta), 如果传入的是-1 , 输出就是字符串日期2020-01-02 def get_date(day_delta): - if day_delta == -1: - now_2 = datetime.datetime.now(tz=None) # 获取当前时间 - print("当前时间为:", now_2) - now_2 = now_2 + timedelta(days=-1) # 日期减1 - now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 - return now_2 - else: - return None + now_2 = datetime.datetime.now(tz=None) # 获取当前时间 + print("当前时间为:", now_2) + now_2 = now_2 + timedelta(days=day_delta) # 日期减1 + now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 + return now_2 -date = get_date(-1) +n = int(input('请输入一个整数:')) +date = get_date(n) print("日期减1后时间为", date) \ No newline at end of file -- Gitee From 8a9c7f3fcb2fbd0dca672d64bd3cf2af143a0722 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Thu, 7 Jan 2021 20:27:48 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" index 96f84e63..5e395c8f 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -31,4 +31,4 @@ def get_date(day_delta): n = int(input('请输入一个整数:')) date = get_date(n) -print("日期减1后时间为", date) \ No newline at end of file +print(date) \ No newline at end of file -- Gitee From 5ed9d2c48b3d15e266a478f53b92b8e50b735810 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Thu, 7 Jan 2021 20:34:42 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\221\250\347\254\254\344\270\200\350\257\276.py" | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" index 5e395c8f..d670d96f 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -23,10 +23,14 @@ print(now_1.__repr__()) def get_date(day_delta): now_2 = datetime.datetime.now(tz=None) # 获取当前时间 - print("当前时间为:", now_2) - now_2 = now_2 + timedelta(days=day_delta) # 日期减1 - now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 - return now_2 + if day_delta == -1: + now_2 = now_2 + timedelta(days=day_delta) # 日期减1 + now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 + return now_2 + else: + now_2 = now_2.strftime("%Y-%m-%d %H:%M:%S") + return now_2 + n = int(input('请输入一个整数:')) -- Gitee From 1bbfa4e7c00d34e2cbb659899fd5e43c0f370400 Mon Sep 17 00:00:00 2001 From: wong <1513445111@qq.com> Date: Fri, 8 Jan 2021 16:08:33 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E5=91=A8=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=AF=BE=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5\221\250\347\254\254\344\270\200\350\257\276.py" | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" index d670d96f..c00164ba 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/2\347\217\255/2\347\217\255_Wong/week04/\347\254\254\345\233\233\345\221\250\347\254\254\344\270\200\350\257\276.py" @@ -23,15 +23,9 @@ print(now_1.__repr__()) def get_date(day_delta): now_2 = datetime.datetime.now(tz=None) # 获取当前时间 - if day_delta == -1: - now_2 = now_2 + timedelta(days=day_delta) # 日期减1 - now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 - return now_2 - else: - now_2 = now_2.strftime("%Y-%m-%d %H:%M:%S") - return now_2 - - + now_2 = now_2 + timedelta(days=day_delta) + now_2 = now_2.strftime("%Y-%m-%d") # 转换时间格式 + return now_2 n = int(input('请输入一个整数:')) date = get_date(n) -- Gitee