上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 23 下一页
摘要: >>> dict({1:2},2=3)SyntaxError: keyword can't be an expression>>> dict({1:2},**{2:3})Traceback (most recent call last): File "", line 1, in dict({1:2},**{2:3})TypeError: keyword arguments must be strings>>> dict({1:2},**{'2':3}){1: 2, '2': 3}& 阅读全文
posted @ 2014-01-07 21:42 LisPythoniC 阅读(773) 评论(0) 推荐(0) 编辑
摘要: 最近读django源码,发现必须了解元类才能理解一些很神奇的行为.发现元类实际上是控制class的创建过程.比如类B继承某个看似平淡无奇的类A之后,你在类B中定义的属性或方法可能会遭到彻底改变.假设我们想实现这么一种需求:创建一个类Child,在这个类中定义的种种字符串属性,都可以当做对应的函数那样调用.例如:class Child(): f1='print'随后,Child.f1就完全和内建函数print等价了.Child.f1('abc')能够打印出abc这个字符串.这样来说,元类的用途看起来可以是:一些高手设计了一个在幕后做了很多工作的元类,另一些开发人员 阅读全文
posted @ 2014-01-07 11:25 LisPythoniC 阅读(327) 评论(0) 推荐(0) 编辑
摘要: #\Python33\Lib\site-packages\django\contrib\auth\models.pyclass UserManager(BaseUserManager): def _create_user(self, username, email, password, is_staff, is_superuser, **extra_fields): """ Creates and saves a User with the given username, email and password. ... 阅读全文
posted @ 2014-01-05 16:08 LisPythoniC 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Basic configuration and use---------------------------Once installed, you can add django-registration to any Django-basedproject you're developing. The default setup will enable userregistration with the following workflow:1. A user signs up for an account by supplying a username, email address 阅读全文
posted @ 2014-01-03 15:16 LisPythoniC 阅读(373) 评论(0) 推荐(0) 编辑
摘要: DoesNotExist at /account/User has no account.Request Method:GETRequest URL:http://127.0.0.1:8000/account/Django Version:1.6.1Exception Type:DoesNotExistException Value:User has no account.Exception Location:/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py in __get__, line 20 阅读全文
posted @ 2014-01-02 00:01 LisPythoniC 阅读(368) 评论(0) 推荐(0) 编辑
摘要: DoesNotExist at /admin/User has no account.Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:1.6.1Exception Type:DoesNotExistException Value:User has no account.Exception Location:/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py in __get__, line 206Pyt 阅读全文
posted @ 2014-01-01 23:59 LisPythoniC 阅读(428) 评论(0) 推荐(0) 编辑
摘要: """Django settings for sitea project.For more information on this file, seehttps://docs.djangoproject.com/en/1.6/topics/settings/For the full list of settings and their values, seehttps://docs.djangoproject.com/en/1.6/ref/settings/"""# Build paths inside the project lik 阅读全文
posted @ 2014-01-01 23:57 LisPythoniC 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 直接:for i in range(1,n+1): print(i) if xls.getCell(i,1,1)=='id': res=[] xls.xlBook.Worksheets(i).Name=xls.xlBook.Worksheets(i).Name.capitalize()才能成功更改每个工作表的名字.这样就不行:for i in range(1,n+1): print(i) if xls.getCell(i,1,1)=='id': res=[] t=xls.xlBook.Worksheets(i).N... 阅读全文
posted @ 2013-12-28 22:06 LisPythoniC 阅读(202) 评论(0) 推荐(0) 编辑
摘要: def f(x): print 'original' if x > 0: return f(x-1) return 0g = fdef f(x): print 'new' return xprint g(5)结果是:originalnew4证明了:1.when g(5) runs, origninal `f`is called,not new `f`.2.as 5>0,'return f(x-1)'is executed3.new`f`is called when `f(x-1)` runs. so the result is 4. 阅读全文
posted @ 2013-12-27 11:23 LisPythoniC 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 今天统计了下某个时刻各进程的内存和CPU使用概况.结果发现,Chrome消耗量真是不一般的大.比Windows主进程都还猛!另外发现百度安全卫士占用CPU也比较猛.powershell下输入:ps | Out-File C:\Users\Nan\Desktop\test.txt然后分析输出数据即可.If you typeget-help get-process -full You will get an explanation of these terms. Here it is:The default display of a process is a table that include. 阅读全文
posted @ 2013-12-25 23:17 LisPythoniC 阅读(452) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 23 下一页