Difficult-Rocket/libs/tools.py

59 lines
1.3 KiB
Python
Raw Normal View History

2020-12-16 06:33:33 +08:00
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
"""
2020-12-23 23:19:16 +08:00
import libs
import decimal
2020-12-16 06:33:33 +08:00
def mbool(thing): # stand for my bool
if (thing == "True") or (thing == 1) or (thing == "1"):
return True
elif (thing == "False") or (thing == 0) or (thing == "0"):
return False
else:
raise ValueError("Need a 'like bool' not anything else")
2020-12-22 18:13:59 +08:00
2020-12-23 23:19:16 +08:00
def D_C(listA, listB): # stand for Duplicate check
2020-12-22 18:13:59 +08:00
"""
usage:\n
input two list\n
the fun will do duplicate check and sort then\n
the fun won't return any thing just change the list now
"""
for unit in listB:
if unit in listA:
listA.remove(unit)
listB.remove(unit)
else:
continue
listA.sort()
listB.sort()
return
2020-12-23 23:19:16 +08:00
def F_Mu(A, B): # stand for float multiple
2020-12-26 00:08:52 +08:00
a = decimal.Decimal(str(A))
b = decimal.Decimal(str(B))
return float(a * b)
2020-12-23 23:19:16 +08:00
def F_D(A, B): # stand for float divided
2020-12-26 00:08:52 +08:00
a = decimal.Decimal(str(A))
b = decimal.Decimal(str(B))
return float(a / b)
2020-12-23 23:19:16 +08:00
2020-12-26 00:08:52 +08:00
def F_A(A, B): # stand for float plus
a = decimal.Decimal(str(A))
b = decimal.Decimal(str(B))
return float(a + b)
2020-12-23 23:19:16 +08:00
def F_Mi(A, B): # stand for float minus
2020-12-26 00:08:52 +08:00
a = decimal.Decimal(str(A))
b = decimal.Decimal(str(B))
return float(a - b)