From 61a80c5e24f3285343c7d275a387daf7599ad52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E7=91=97=E6=9D=B0?= <3695888@qq.com> Date: Mon, 21 Dec 2020 22:48:43 +0800 Subject: [PATCH] =?UTF-8?q?FINALLY=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/Game_threads/__init__.py | 1 - libs/{Game_threads/calculations.py => P_C.py} | 28 +++++++++++++++++-- libs/__init__.py | 3 +- test.py | 19 +++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) rename libs/{Game_threads/calculations.py => P_C.py} (58%) create mode 100644 test.py diff --git a/libs/Game_threads/__init__.py b/libs/Game_threads/__init__.py index b49957e..26d0a8f 100644 --- a/libs/Game_threads/__init__.py +++ b/libs/Game_threads/__init__.py @@ -5,4 +5,3 @@ mail: 3695888@qq.com # import folders # import in this forder -from libs.Game_threads import calculations \ No newline at end of file diff --git a/libs/Game_threads/calculations.py b/libs/P_C.py similarity index 58% rename from libs/Game_threads/calculations.py rename to libs/P_C.py index 7cfb1a6..c3da539 100644 --- a/libs/Game_threads/calculations.py +++ b/libs/P_C.py @@ -24,14 +24,16 @@ def P_C_M(A, B): # stand for Physics Calculation multiple else: Float = float(Float) Int = int(Int) - Unit1 = A[2].extend(B[2]) + Unit1 = [].append(A[2].extend(B[2])) Unit2 = [] for unit in B[3]: - if unit in Unit1: + if unit in [Unit1]: n = Unit1.index(unit) Unit1.pop(n) else: Unit2.append(unit) + if Unit1 == None: + Unit1 = [] C = [Float, Int, Unit1, Unit2] return C @@ -42,4 +44,26 @@ def P_C_D(A, B): # stand for Physics Calculation divide A & B list format:docs.basic_config.json:basic_number """ C = [0.0, 1, [], []] + Float = A[0] / B[0] + Int = A[1] - B[1] + if Float >= 10: + Float /= 10 + Int += 1 + elif Float <= 0.01: + Float *= 10 + Int -= 1 + else: + Float = float(Float) + Int = int(Int) + Unit1 = A[2].extend(B[3]) + Unit2 = [] + for unit in B[2]: + if unit in [Unit1]: + n = Unit1.index(unit) + Unit1.pop(n) + else: + Unit2.append(unit) + if Unit1 == None: + Unit1 = [] + C = [Float, Int, Unit1, Unit2] return C diff --git a/libs/__init__.py b/libs/__init__.py index 59d22d8..00cbbb6 100644 --- a/libs/__init__.py +++ b/libs/__init__.py @@ -6,8 +6,9 @@ mail: 3695888@qq.com import libs.Game_threads # import in this forder +import libs.P_C import libs.main import libs.loads import libs.setup -import libs.render_thread import libs.delivery +import libs.render_thread diff --git a/test.py b/test.py new file mode 100644 index 0000000..777f7fb --- /dev/null +++ b/test.py @@ -0,0 +1,19 @@ +""" +writen by shenjackyuanjie +mail: 3695888@qq.com +""" + +import libs + + +A = [2.573, 3, ["m", "kg"], ["N", "s"]] +B = [0.245, -7, ["N", "kg"], ["m", "s"]] + +print("A = " , A) +print("B = " , B) + +C = libs.P_C.P_C_M(A, B) +D = libs.P_C.P_C_D(A, B) + +print("A × B = " , C) +print("A ÷ B = " , D)