python
阿集
呵呵
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python判断语句is与==的区别
python的is比较两个对象是否相等,==判断的是两个对象的值是否相等 比如:def is_undefined1(name): if name is u'undefined': return True return Falsedef is_undefined2(name): if name == u'undefined': return T原创 2016-04-06 12:56:27 · 594 阅读 · 0 评论 -
切换python版本
alternatives这么好的机制用起来呀。shell里执行:sudo update-alternatives –install /usr/bin/python python /usr/bin/python2 100 sudo update-alternatives –install /usr/bin/python python /usr/bin/python3 150 此时你会发现如果要切换转载 2016-03-26 18:56:25 · 769 阅读 · 0 评论 -
python编码问题
首先要搞清楚,字符串在Python内部的表示是unicode编码. 因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(encode)成另一种编码。 decode的作用是将其他编码的字符串转换成unicode编码, 如str1.decode('gb2312'),表示将gb2312编码的字符串转换成unicod转载 2016-04-25 21:38:51 · 283 阅读 · 0 评论 -
django获取url参数总结
1 无参数情况配置URL及其视图如下:(r'^hello/$', hello) def hello(request): return HttpResponse("Hello World")访问http://127.0.0.1:8000/hello,输出结果为“Hello World”2 传递一个参数 配置URL及其视图如下,URL中通过正则指定一个参数:(r'^plist/(.转载 2016-04-11 03:06:29 · 2842 阅读 · 0 评论
分享