mirror of
https://github.com/djimboy/djimbo_template_aio3.git
synced 2026-07-25 01:34:30 +00:00
Update
This commit is contained in:
@@ -264,22 +264,19 @@ def is_bool(value: Union[bool, str, int]) -> bool:
|
|||||||
|
|
||||||
######################################## ЧИСЛА ########################################
|
######################################## ЧИСЛА ########################################
|
||||||
# Преобразование экспоненциальных чисел в читаемый вид (1e-06 -> 0.000001)
|
# Преобразование экспоненциальных чисел в читаемый вид (1e-06 -> 0.000001)
|
||||||
def snum(amount: float, remains=0) -> str:
|
def snum(amount: Union[int, float]) -> str:
|
||||||
str_amount = f"{float(amount):8f}"
|
str_amount = str(amount)
|
||||||
|
|
||||||
if remains != 0:
|
if "e" in str_amount:
|
||||||
if "." in str_amount:
|
decial = str_amount.split("e")
|
||||||
remains_find = str_amount.find(".")
|
str_amount = format(((float(decial[0])) * (10 ** int(decial[1]))), ".8f")
|
||||||
remains_save = remains_find + 8 - (8 - remains) + 1
|
|
||||||
|
|
||||||
str_amount = str_amount[:remains_save]
|
|
||||||
|
|
||||||
if "." in str(str_amount):
|
if "." in str(str_amount):
|
||||||
while str(str_amount).endswith('0'): str_amount = str(str_amount)[:-1]
|
while str(str_amount).endswith("0"): str_amount = str(str_amount)[:-1]
|
||||||
|
|
||||||
if str(str_amount).endswith('.'): str_amount = str(str_amount)[:-1]
|
if str(str_amount).endswith("."): str_amount = str(str_amount)[:-1]
|
||||||
|
|
||||||
return str(str_amount)
|
return str_amount
|
||||||
|
|
||||||
|
|
||||||
# Конвертация любого числа в вещественное, с удалением нулей в конце (remains - округление)
|
# Конвертация любого числа в вещественное, с удалением нулей в конце (remains - округление)
|
||||||
|
|||||||
Reference in New Issue
Block a user