03 2012 档案

摘要:http://www.cnblogs.com/harrychinese/archive/2012/01/19/change_python_default_encoding.html 今天碰到了 python 编码问题, 报错信息如下Traceback (most recent call last)... 阅读全文
posted @ 2012-03-19 18:43 samlee 阅读(2810) 评论(0) 推荐(1)
摘要:In [43]: s = 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxx'In [44]: [s[idx:idx+4] for idx in range(len(s)) if idx%4==0]Out[44]: ['axxx', 'xxxx', 'xxxx', 'xxxx', '... 阅读全文
posted @ 2012-03-12 15:59 samlee 阅读(325) 评论(0) 推荐(0)
摘要:#单个unicode字符串的长度为1, 单个utf-8字符的长度为3 In [3]: u = u"这是一个中文字符串"In [4]: len(u)Out[4]: 9In [5]: utf8str = u.encode("utf-8")In [6]: len(utf8str)Out[6]: 27... 阅读全文
posted @ 2012-03-11 16:32 samlee 阅读(2194) 评论(0) 推荐(0)