ezKit 1.10.9__tar.gz → 1.11.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.10.9
3
+ Version: 1.11.1
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -235,6 +235,30 @@ def division(
235
235
  # --------------------------------------------------------------------------------------------------
236
236
 
237
237
 
238
+ def format_float(number: float | int, index: int = 2, limit: int = 3) -> float | None:
239
+ """格式化浮点数"""
240
+
241
+ # 以两位和三位为例, 如果结果为假, 即: 0, 0.0, 0.00 等,保留小数点后的三位, 否则保留小数点后的两位.
242
+
243
+ # 检查参数
244
+ if not check_arguments([
245
+ (number, (float, int), "number"),
246
+ (index, int, "index"),
247
+ (limit, int, "limit")
248
+ ]):
249
+ return False
250
+
251
+ try:
252
+ rounded_float = round(number, index)
253
+ return rounded_float if bool(rounded_float) else round(number, limit)
254
+ except Exception as e:
255
+ logger.exception(e)
256
+ return None
257
+
258
+
259
+ # --------------------------------------------------------------------------------------------------
260
+
261
+
238
262
  def check_file_type(
239
263
  file_object: str,
240
264
  file_type: str
@@ -394,26 +418,19 @@ def list_print_by_step(
394
418
 
395
419
  try:
396
420
 
397
- # result: list = []
398
-
399
- # if len(data) <= step:
400
- # result.append(data)
401
- # else:
402
- # data_list = list_split(data, step, debug=debug)
403
- # if data_list is None or isTrue(data_list, list) is False:
404
- # return False
405
- # result = data_list
406
-
407
- # for item in result:
408
- # print(*item, sep=separator)
409
-
410
- # return True
411
-
412
421
  # 打印
413
422
  for i, v in enumerate(data):
423
+
414
424
  if i > 0 and i % step == 0:
415
425
  print()
416
- print(v, end=separator)
426
+
427
+ # print(v, end=separator)
428
+
429
+ # 每行最后一个 或者 所有数据最后一个, 不打印分隔符
430
+ if ((i % step) == (step - 1)) or ((i + 1) == len(data)):
431
+ print(v, end='')
432
+ else:
433
+ print(v, end=separator)
417
434
 
418
435
  print()
419
436
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.10.9
3
+ Version: 1.11.1
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -3,7 +3,7 @@ from setuptools import find_packages, setup
3
3
 
4
4
  setup(
5
5
  name='ezKit',
6
- version='1.10.9',
6
+ version='1.11.1',
7
7
  author='septvean',
8
8
  author_email='septvean@gmail.com',
9
9
  description='Easy Kit',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes