1. 构造二维列表: 比如我现在需要一个100*100的二维列表: a = [] for i in range(100): a.append([]) for j in range(100): a[i].append(data) # 这里插入列表元素的值 2. 排序字典: 比如我现在想要python的字典全部按键排序存放: from collections import OrderedDict d = OrderedDict() d['c'] = 1 d['k'] = 2 d['z'] = 3 d
不断报错 coercing to Unicode : 不要用+连接字符串,要用格式化字符串 None的问题:只能用 or “”的方式来解决了 not all arguments converted during string formatting:%前后对应不上 为了调试一条复杂的sql语句,耗费了半天!python对于这种字符串操作的确不敢恭维.
建立AVL树 class AVLNode(object): def __init__(self,data): self.data = data self.lchild = None self.rchild = None self.parent = None self.bf = 0 class AVLTree(object) def __init__(self,li=None) self.root = None if li: for val in li: self.insert(self.root