01 2014 档案

摘要:今天,我总算搞清楚“回车”(carriage return)和“换行”(line feed)这两个概念的来历和区别了。在计算机还没有出现之前,有一种叫做电传打字机(Teletype Model 33)的玩意,每秒钟可以打10个字符。但是它有一个问题,就是打完一行换行的时候,要用去0.2秒,正好可以打两个字符。要是在这0.2秒里面,又有新的字符传过来,那么这个字符将丢失。于是,研制人员想了个办法解决这个问题,就是在每行后面加两个表示结束的字符。一个叫做“回车”,告诉打字机把打印头定位在左边界;另一个叫做“换行”,告诉打字机把纸向下移一行。这就是“换行”和“回车”的来历,从它们的英语名字上也可以看 阅读全文
posted @ 2014-01-31 11:33 LisPythoniC 阅读(366) 评论(0) 推荐(0)
摘要:>>> import datetime>>> class c(): @property def noww(self): return datetime.datetime.now() >>> c.noww>>> x=c()>>> x.nowwdatetime.datetime(2014, 1, 27, 13, 17, 14, 725610)>>> x.nowwdatetime.datetime(2014, 1, 27, 13, 17, 27, 8740)>>> x.now 阅读全文
posted @ 2014-01-27 13:19 LisPythoniC 阅读(246) 评论(0) 推荐(0)
摘要:>>> def f(): a=1 return [i+a for i in range(3)]>>> f()[1, 2, 3]>>> def f(): a=1 return [i+eval('a') for i in range(3)]>>> f()Traceback (most recent call last): File "", line 1, in f() File "", line 3, in f return [i+eval('a') fo 阅读全文
posted @ 2014-01-26 17:57 LisPythoniC 阅读(239) 评论(0) 推荐(0)
摘要:>>> 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 阅读(785) 评论(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 阅读(347) 评论(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 阅读(205) 评论(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 阅读(397) 评论(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 阅读(376) 评论(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 阅读(439) 评论(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 阅读(239) 评论(0) 推荐(0)