常见于从数据库中取出来的字符串存储的数组,需要转为list
class _UtilPort(object):
def _char2IntList(self, char):
if len(char) <= 0:
return []
return list(set(map(int, char.split(','))))
def _intList2char(self, int_list):
if len(int_list) <= 0:
return ''
return ','.join(str(i) for i in int_list)
a = "1,2,3"
b = "3,3,4,5"
c = []
c = c+_UtilPort()._char2IntList(a)+_UtilPort()._char2IntList(b)
print(c) # [1,2,3,3,4,5]