摘要: 字典 一.创建字典 方法①: >>> dict1 = {} >>> dict2 = {'name': 'earth', 'port': 80} >>> dict1, dict2 ({}, {'port': 80, 'name': 'earth'}) 方法②:从Python 2... 阅读全文
posted @ 2013-10-21 21:09 唐僧吃肉 阅读(1584) 评论(0) 推荐(0) 编辑
摘要: 我的关键结构比如 struct{ int a; int b; int c; }s; 因为这三个数据是基本信息,可以唯一区别一个设备。拿这样一个数据结构作为索引就能找到每个设备。 我现在想这么用 map 因为map是二叉树,好像没法拿结构体比较大小,去索引,所以把结构体... 阅读全文
posted @ 2013-10-21 15:11 唐僧吃肉 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 1 decode和encode方法 字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(encode)成另一种编码。 decode的作用是将其... 阅读全文
posted @ 2013-10-21 14:33 唐僧吃肉 阅读(256) 评论(0) 推荐(0) 编辑