From 929c8390f1a4a952b9b6e0d342084d994de80f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Tue, 12 Jan 2021 23:42:15 +0800 Subject: [PATCH 01/10] init commit --- .../123.py" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" new file mode 100644 index 00000000..d800886d --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" @@ -0,0 +1 @@ +123 \ No newline at end of file -- Gitee From 441a145d93b82f65d34b8105d31619946443d420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Tue, 12 Jan 2021 23:45:00 +0800 Subject: [PATCH 02/10] init commit --- .../123.py" | 1 - 1 file changed, 1 deletion(-) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" index d800886d..e69de29b 100644 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" @@ -1 +0,0 @@ -123 \ No newline at end of file -- Gitee From 966e679f87a95ba500bef7b224d0bd3598403da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Wed, 13 Jan 2021 00:11:16 +0800 Subject: [PATCH 03/10] init commit --- .../123.py" | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" deleted file mode 100644 index e69de29b..00000000 -- Gitee From ab832ac697c030736973280f4f802443fb517515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Wed, 13 Jan 2021 00:13:08 +0800 Subject: [PATCH 04/10] init commit --- .../123.py" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" new file mode 100644 index 00000000..d800886d --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" @@ -0,0 +1 @@ +123 \ No newline at end of file -- Gitee From 86291049e7c2539aa43bbdb26359c042be3c00c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Wed, 13 Jan 2021 00:14:58 +0800 Subject: [PATCH 05/10] init commit --- .../123.py" | 1 - 1 file changed, 1 deletion(-) delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" deleted file mode 100644 index d800886d..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/123.py" +++ /dev/null @@ -1 +0,0 @@ -123 \ No newline at end of file -- Gitee From 1a779039a9d993d27bca7ecc5376766e15e3156a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Wed, 13 Jan 2021 00:15:35 +0800 Subject: [PATCH 06/10] init commit --- .../1234.py" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" new file mode 100644 index 00000000..4632e068 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" @@ -0,0 +1 @@ +123456 \ No newline at end of file -- Gitee From 5b02dc8b0984c6b44713f246ab404d67507fab05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Wed, 13 Jan 2021 00:16:02 +0800 Subject: [PATCH 07/10] init commit --- .../1234.py" | 1 - 1 file changed, 1 deletion(-) delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" deleted file mode 100644 index 4632e068..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/1234.py" +++ /dev/null @@ -1 +0,0 @@ -123456 \ No newline at end of file -- Gitee From b68f32f2b3c5bf52b1f293a9650492ed79b78822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Thu, 14 Jan 2021 22:22:33 +0800 Subject: [PATCH 08/10] init commit --- .../21.01.05.py" | 44 ----------- .../.keep" | 0 .../21_01_12.py" | 40 ---------- .../.keep" | 0 .../21_01_09.py" | 48 ------------ .../.keep" | 0 .../21_01_07.py" | 76 ------------------- 7 files changed, 208 deletions(-) delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\347\254\254\344\270\200\350\212\202\344\275\234\344\270\232/21.01.05.py" delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" delete mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\347\254\254\344\270\200\350\212\202\344\275\234\344\270\232/21.01.05.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\347\254\254\344\270\200\350\212\202\344\275\234\344\270\232/21.01.05.py" deleted file mode 100644 index 6013b2a5..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\347\254\254\344\270\200\350\212\202\344\275\234\344\270\232/21.01.05.py" +++ /dev/null @@ -1,44 +0,0 @@ -import time, datetime - -#datetime. datetime 转换成 str -t = datetime. datetime. now(tz = None) -print(t.strftime("%Y-%m-%d %H:%M:%S")) - -# str 转换成 datetime. datetime -t = datetime. datetime. now(tz = None) -a = t.strftime("%Y-%m-%d %H:%M:%S") -b = datetime. datetime. strptime(a, "%Y-%m-%d %H:%M:%S") - -#datetime.datetime 转换成 timestamp -t = datetime. datetime. now(tz = None) -c = t. timestamp() -print(c) - -#timestamp 转换成 datetime. datetime -d = datetime.datetime.fromtimestamp(c, tz = None) -print(d) - -#timestamp 转换成 str -e = datetime.datetime.fromtimestamp(c, tz = None) -f = e.strftime("%Y-%m-%d %H:%M:%S") -print(f) - -# str 转换成 timestamp -g = datetime.datetime.strptime(f, "%Y-%m-%d %H:%M:%S") -h = g.timestamp() -print(h) - -#封闭一个函数,如果传入的是-1,输出的就是字符串时间 -import datetime -def get_date(): - n = input("若想知道当前日期,请输入-1:") - if n == "-1": - t = datetime.datetime.now(tz=None) - print(t.strftime("%Y-%m-%d")) - else: - print("您输入的不是-1,请重新输入!") - get_date() - return - -get_date() - diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" deleted file mode 100644 index e69de29b..00000000 diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" deleted file mode 100644 index 18fcb388..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" +++ /dev/null @@ -1,40 +0,0 @@ -from threading import Thread -import time -from multiprocessing import process - -#第一问,实现一个多线程程序 -def one(num): - for i in range(num): - print(f"I am {i}") - time.sleep(0.5) - -def two(num): - for i in range(num): - print(f"you are {i}") - time.sleep(0.5) - -def main(): - t_one = Thread (target = one, args = (5, )) - t_two = Thread (target = two, args = (6, )) - t_one.start() - t_two.start() - -if __name__ == '__main__': - main() - -#第二部,将多线程改为多进程 -def one(num): - for i in range(num): - print(f"I am {i}") - - -def two(num): - for i in range(num): - print(f"you are {i}") - - -def main(): - p_one = process (target = one, args = (5, )) - p_two = process(target = two, args = (6, )) - p_one.start() - p_two.start() \ 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/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" deleted file mode 100644 index e69de29b..00000000 diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" deleted file mode 100644 index a276c066..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" +++ /dev/null @@ -1,48 +0,0 @@ -#第一问 -class MyMath: - @staticmethod - def add(a, b): - return a + b - - def sub(a, b): - return a - b - - def mul(a, b): - return a * b - - def div(a, b): - return a / b - - def ediv(a, b): - return a // b - - def rem(a, b): - return a % b - - def sqrt(a, b): - return float(a ** (1 / 2)) - -print(MyMath.ediv(10,5)) - -#第二问 -class Cat: - cute_cat = True - __mycat = {"David": 2} - def __init__(self, name, age): - - self. name = name - self. __age = age - - @classmethod - def __new__(cls, *args, **kwargs): - print("猫咪真可爱") - return super().__new__(cls) - - def __str__(self): - return "名字是:%s , 年龄是:%d" % (self. name, self. __age) - - - -print(Cat. _Cat__mycat) -tom = Cat("汤姆", 30) -print(tom) \ 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/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" deleted file mode 100644 index e69de29b..00000000 diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" deleted file mode 100644 index f0938caa..00000000 --- "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" +++ /dev/null @@ -1,76 +0,0 @@ -#第一问,用类封装一个MyMath类 -class MyMath: - def add(self, a, b): - return a + b - - def sub(self, a, b): - return a - b - - def mul(self, a, b): - return a * b - - def div(self, a, b): - return a / b - - def ediv(self, a, b): - return a // b - - def rem(self, a, b): - return a % b - - def sqrt(self, a, b): - return float(a ** (1 / 2)) -a = MyMath() -a. add(10, 5) -print(a) - -# 定义类 -#第一个 -class Cat: - def __init__(self, a, b): - self. name = a - self. age = b - - def __str__(self): - return "名字是:%s , 年龄是:%d" % (self. name, self. age) - - def eat(self): - print(f"{self. name}在吃鱼") - - def drink(self): - print(f"{self. name}在喝牛奶") - -tom = Cat("汤姆", 30) -a = Cat("David", 20) -a. eat() - -#第二个 -class MyClass: - countnum = 0 - def __init__(self, name, age): - self. name = name - self. age = age - MyClass. countnum += 1 - - def totalnum(self): - print("总人数为:", MyClass. countnum) - - def displaystudent(self): - print("名字:", self. name, " ", "年龄:", self. age) - - -#第三问,创建相应子类 -class firstchild(MyClass): - def great(self): - print(f"{self. name}是大神") - -class secondchild(MyClass): - def good(self): - print(f"我们都得向{self. name}看齐!") - -A = firstchild("小天", 20) -B = secondchild("小天", 20) -A. great() -B. good() -print(A) -print(B) -- Gitee From 540e04d849c929dff863577e470f0f74192f423f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Thu, 14 Jan 2021 22:23:38 +0800 Subject: [PATCH 09/10] init commit --- .../21.01.05.py" | 44 +++++++++++ .../.keep" | 0 .../21_01_09.py" | 48 ++++++++++++ .../.keep" | 0 .../21_01_07.py" | 76 +++++++++++++++++++ 5 files changed, 168 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.05.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.05.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.05.py" new file mode 100644 index 00000000..6013b2a5 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21.01.05.py" @@ -0,0 +1,44 @@ +import time, datetime + +#datetime. datetime 转换成 str +t = datetime. datetime. now(tz = None) +print(t.strftime("%Y-%m-%d %H:%M:%S")) + +# str 转换成 datetime. datetime +t = datetime. datetime. now(tz = None) +a = t.strftime("%Y-%m-%d %H:%M:%S") +b = datetime. datetime. strptime(a, "%Y-%m-%d %H:%M:%S") + +#datetime.datetime 转换成 timestamp +t = datetime. datetime. now(tz = None) +c = t. timestamp() +print(c) + +#timestamp 转换成 datetime. datetime +d = datetime.datetime.fromtimestamp(c, tz = None) +print(d) + +#timestamp 转换成 str +e = datetime.datetime.fromtimestamp(c, tz = None) +f = e.strftime("%Y-%m-%d %H:%M:%S") +print(f) + +# str 转换成 timestamp +g = datetime.datetime.strptime(f, "%Y-%m-%d %H:%M:%S") +h = g.timestamp() +print(h) + +#封闭一个函数,如果传入的是-1,输出的就是字符串时间 +import datetime +def get_date(): + n = input("若想知道当前日期,请输入-1:") + if n == "-1": + t = datetime.datetime.now(tz=None) + print(t.strftime("%Y-%m-%d")) + else: + print("您输入的不是-1,请重新输入!") + get_date() + return + +get_date() + diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" new file mode 100644 index 00000000..e69de29b diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" new file mode 100644 index 00000000..cd12e494 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\270\211\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_09.py" @@ -0,0 +1,48 @@ +#第一问 +class MyMath: + @staticmethod + def add(a, b): + return a + b + + def sub(a, b): + return a - b + + def mul(a, b): + return a * b + + def div(a, b): + return a / b + + def ediv(a, b): + return a // b + + def rem(a, b): + return a % b + + def sqrt(a, b): + return float(a ** (1 / 2)) + +print(MyMath.ediv(10,5)) + +#第二问 +class Cat: + cute_cat = True + __mycat = {"David": 2} + def __init__(self, name, age): + + self. name = name + self. __age = age + + @classmethod + def __new__(cls, *args, **kwargs): + print("猫咪真可爱") + return super().__new__(cls) + + def __str__(self): + return "名字是:%s , 年龄是:%d" % (self. name, self. __age) + + + +print(Cat. _Cat__mycat) +tom = Cat("汤姆", 30) +print(tom) \ 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/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" new file mode 100644 index 00000000..e69de29b diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" new file mode 100644 index 00000000..dfc26950 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\345\233\233\345\221\250_\344\275\234\344\270\232/\347\254\254\345\233\233\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_07.py" @@ -0,0 +1,76 @@ +#第一问,用类封装一个MyMath类 +class MyMath: + def add(self, a, b): + return a + b + + def sub(self, a, b): + return a - b + + def mul(self, a, b): + return a * b + + def div(self, a, b): + return a / b + + def ediv(self, a, b): + return a // b + + def rem(self, a, b): + return a % b + + def sqrt(self, a, b): + return float(a ** (1 / 2)) +a = MyMath() +a. add(10, 5) +print(a) + +# 定义类 +#第一个 +class Cat: + def __init__(self, a, b): + self. name = a + self. age = b + + def __str__(self): + return "名字是:%s , 年龄是:%d" % (self. name, self. age) + + def eat(self): + print(f"{self. name}在吃鱼") + + def drink(self): + print(f"{self. name}在喝牛奶") + +tom = Cat("汤姆", 30) +a = Cat("David", 20) +a. eat() + +#第二个 +class MyClass: + countnum = 0 + def __init__(self, name, age): + self. name = name + self. age = age + MyClass. countnum += 1 + + def totalnum(self): + print("总人数为:", MyClass. countnum) + + def displaystudent(self): + print("名字:", self. name, " ", "年龄:", self. age) + + +#第三问,创建相应子类 +class firstchild(MyClass): + def great(self): + print(f"{self. name}是大神") + +class secondchild(MyClass): + def good(self): + print(f"我们都得向{self. name}看齐!") + +A = firstchild("小天", 20) +B = secondchild("小天", 20) +A. great() +B. good() +print(A) +print(B) -- Gitee From 4430eda57906d49b0f35efed538470a826c713bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=99=9A=E5=B9=B3?= <8437069+zhang-xuping@user.noreply.gitee.com> Date: Thu, 14 Jan 2021 22:24:18 +0800 Subject: [PATCH 10/10] init commit --- .../.keep" | 0 .../21_01_12.py" | 40 +++++++++++++ .../21_01_14.py" | 57 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" create mode 100644 "\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_14.py" diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/.keep" new file mode 100644 index 00000000..e69de29b diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" new file mode 100644 index 00000000..dbb32c56 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\270\200\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_12.py" @@ -0,0 +1,40 @@ +from threading import Thread +import time +from multiprocessing import process + +#第一问,实现一个多线程程序 +def one(num): + for i in range(num): + print(f"I am {i}") + time.sleep(0.5) + +def two(num): + for i in range(num): + print(f"you are {i}") + time.sleep(0.5) + +def main(): + t_one = Thread (target = one, args = (5, )) + t_two = Thread (target = two, args = (6, )) + t_one.start() + t_two.start() + +if __name__ == '__main__': + main() + +#第二部,将多线程改为多进程 +def one(num): + for i in range(num): + print(f"I am {i}") + + +def two(num): + for i in range(num): + print(f"you are {i}") + + +def main(): + p_one = process (target = one, args = (5, )) + p_two = process(target = two, args = (6, )) + p_one.start() + p_two.start() \ 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/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_14.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_14.py" new file mode 100644 index 00000000..5ac8228c --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\272\224\345\221\250\344\275\234\344\270\232/\347\254\254\344\272\224\345\221\250-\347\254\254\344\272\214\350\212\202-\344\275\234\344\270\232\346\217\220\344\272\244/21_01_14.py" @@ -0,0 +1,57 @@ +from threading import Thread, Lock +import time +from multiprocessing import Process, Lock, Queue + +#第一问 +#多进程锁 +def one(num, lock): + with lock: + for i in range(num): + print(f"I am {i}") + + + +def main(): + lock = Lock() + t_one = Process (target = one, args = (5, lock)) + t_one.start() + +if __name__ == '__main__': + main() + +#多线程锁 +a = 0 +lock = Lock() +def two(): + global a + for i in range(10**3): + with lock: + a += 1 + a -= 1 + + + +def main(): + t_two = Thread (target = two) + t_two.start() + print(a) + +if __name__ == '__main__': + main() + +#第二问,把进程通过Queue来实现进程通信 +def three(num, my_queue): + my_queue. put(num) + +if __name__ == '__main__': + my_queue = Queue() + for i in range(10): + p_three = Process (target = three, args = (i, my_queue)) + p_three.start() + + while True: + print(my_queue.get()) + + + + -- Gitee