8
8
# @Description : 包含基本的文件读写,指定扩展名文件查找等基本工具
9
9
10
10
11
- __version__ = "0.22.16 "
11
+ __version__ = "0.22.17 "
12
12
13
13
14
14
import json
22
22
from gitopenlib .utils import basics as gb
23
23
24
24
25
+ def time_now ():
26
+ """获取当前时间,包括时间戳和格式化后的时间。
27
+
28
+ Returns
29
+ -------
30
+ Tuple[int, str]:
31
+ 时间戳,格式化后的时间
32
+ """
33
+ time_stamp = time .time ()
34
+ time_local = time .localtime (time_stamp )
35
+ time_format = time .strftime ("%Y-%m-%d %H:%M:%S" , time_local )
36
+ return time_stamp , time_format
37
+
38
+
25
39
def quit () -> None :
26
40
"""用于临时打断程序,方便调试。"""
27
41
lineno = sys ._getframe (1 ).f_lineno
@@ -203,8 +217,7 @@ def split_strip(
203
217
for item in strings :
204
218
item = str (item ).strip ()
205
219
result .append (
206
- gb .remove_0_str ([it .strip ()
207
- for it in item .split (sep , maxsplit )])
220
+ gb .remove_0_str ([it .strip () for it in item .split (sep , maxsplit )])
208
221
)
209
222
return result
210
223
@@ -353,13 +366,17 @@ def dict2json(data: dict) -> str:
353
366
str:
354
367
返回json字符串。
355
368
"""
369
+
356
370
def set_default (value ):
357
371
if isinstance (value , set ):
358
372
temp = list (value )
359
373
temp .sort ()
360
374
return temp
361
375
raise TypeError
362
- return json .dumps (data , ensure_ascii = False , separators = ["," , ":" ], default = set_default )
376
+
377
+ return json .dumps (
378
+ data , ensure_ascii = False , separators = ["," , ":" ], default = set_default
379
+ )
363
380
364
381
365
382
def json2dict (astr : str ) -> dict :
@@ -475,7 +492,7 @@ def chunks(arr, m) -> List[List]:
475
492
分割后的每个子list都是返回结果list的一个元素。
476
493
"""
477
494
n = int (math .ceil (len (arr ) / float (m )))
478
- return [arr [i : i + n ] for i in range (0 , len (arr ), n )]
495
+ return [arr [i : i + n ] for i in range (0 , len (arr ), n )]
479
496
480
497
481
498
def chunks1 (arr , size ) -> List [List ]:
@@ -491,7 +508,7 @@ def chunks1(arr, size) -> List[List]:
491
508
List[List]:
492
509
分割后的每个子list都是返回结果list的一个元素。
493
510
"""
494
- chunked_list = [arr [i : i + size ] for i in range (0 , len (arr ), size )]
511
+ chunked_list = [arr [i : i + size ] for i in range (0 , len (arr ), size )]
495
512
return chunked_list
496
513
497
514
0 commit comments