forked from intohole/moodstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
57 lines (30 loc) · 919 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#coding=utf-8
class Node(object):
'''
创建多叉树的过程 ,
创建每个元素都是Node , 每个Node 都有孩子节点(Node)
'''
def __init__(self , data):
self.data = data
self.__child = {}
def __getitem__(self , key):
'''
得到一个Node child节点
'''
if key in self.__child.keys():
return self.__child[key]
else:
return None
def __setitem__(self , key , value):
if key:
if key not in self.__child.keys() and isinstance(value , Node):
self.__child[key] = value
return
raise TypeError , 'key is null or value is not Node or int string etc'
def create_tree(self , datas , attrs):
'''
'''
attr = find_best_feather(datas , attrs)
split_data(datas , attr )
if __name__ == '__main__':
pass