From a5987bfd56e28dd1433e0bd5fdad10d2f066593c Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 7 Dec 2020 11:52:45 +0800 Subject: [PATCH] bugfix --- appPublic/dictExt.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/appPublic/dictExt.py b/appPublic/dictExt.py index 4230614..52f247c 100644 --- a/appPublic/dictExt.py +++ b/appPublic/dictExt.py @@ -1,4 +1,22 @@ +def arrayExtend(s,addon): + ret = [] + s_cnt = len(s) + a_cnt = len(addon) + for i,v in enumerate(addon): + if i < s_cnt: + if type(v)!=type(s[i]): + ret.append(v) + continue + if isinstance(v,dict): + x = dictExtend(v,s[i]) + ret.append(x) + continue + ret.append(v) + if s_cnt < a_cnt: + ret += s[i:] + return ret + def dictExtend(s,addon): ret = {} ret.update(s) @@ -14,7 +32,7 @@ def dictExtend(s,addon): ret[k] = dictExtend(ret[k],v) continue if type(v)==type([]): - ret[k] = ret[k] + v + ret[k] = arrayExtend(ret[k],v) continue ret[k] = v return ret