class TreeNode:
def __init__(self,val):
self.val = val
self.lchild = None
self.rchild = None
def FloorOrder(root):
su = []
su.append(root)
for item in su:
if item.lchild:
su.append(item.lchild)
if item.rchild:
su.append(item.rchild)
for i in su:
print(i.val,end=" ")
a = TreeNode(3)
b = TreeNode(1)
c = TreeNode(4)
d = TreeNode(6)
f = TreeNode(2)
g = TreeNode(7)
a.lchild = b
a.rchild = f
b.lchild = c
b.rchild = d
c.lchild = g
root = a
FloorOrder(root)
简单实现层序遍历