Posts

让Django通过网易163邮箱报告异常和错误(exceptions and errors)

Image
Django需要的EMAIL_HOST_PASSWORD不一定是你的邮箱登录密码,只有开启了网易邮箱smtp服务之后才会有EMAIL_HOST_PASSWORD,这和一般别的邮箱不同(比如139、189等邮箱,目前EMAIL_HOST_PASSWORD就是登录密码)。下面我们就来获取要用网易邮箱的EMAIL_HOST_PASSWORD。 首先不要以网易邮箱简约版登陆,因为现阶段简约版登陆后找不到我们接下来的设置选项 登陆后按照箭头所示点击 再次点击箭头所示之处 按要求设置就是了。获得的授权码就是EMAIL_HOST_PASSWORD,接下来就是具体的配置了,问题也不少,请看http://redstoneleo.blogspot.com/2016/12/email-reporting-exceptions-and-errors_30.html

email reporting exceptions and errors using AdminEmailHandler and SMTPHandler

The Django doc says: In order to send email, EMAIL_HOST, EMAIL_HOST_USER and EMAIL_HOST_PASSWORD are at the very least needed, but as I tested, we should also specify SERVER_EMAIL, and only when SERVER_EMAIL is equal to EMAIL_HOST_USER so can send the email, e.g. EMAIL_HOST = 'smtp.163.com' SERVER_EMAIL = '234327894-cold@163.com' # EMAIL_HOST_USER = '234327894-cold@163.com' # EMAIL_HOST_PASSWORD = '234327894123' # Django uses AdminEmailHandler to send an email to the site admins for each log message it receives. Besides Django, we could also use Python’s logging.handlers.SMTPHandler(mailhost, fromaddr, toaddrs, subject, credentials=None, secure=None, timeout=1.0) to do the same. For example, put the following code in views.py (do change to your account), it will email reporting unhandled exceptions and results in an internal server error (HTTP status code 500). import logging logging.basicConfig(format='%(asctime)s %(message)s...

using BeautifulSoup to grab CData

one thing you need to be care of when using BeautifulSoup grabbing CData is not to use lxml parser, By default, lxml's parser will strip CDATA sections from the tree and replace them by their plain text content, learn more here  https://groups.google.com/forum/?fromgroups=#!topic/beautifulsoup/whLj3jMRq7g >>> from bs4 import BeautifulSoup >>> import bs4 >>> s = '''<?xml version="1.0" ?> <foo> <bar><![CDATA[ aaaaaaaaaaaaa ]]></bar> </foo>''' >>> soup = BeautifulSoup ( s , "html.parser" ) >>> soup . find ( text = lambda tag : isinstance ( tag , bs4 . CData )). string . strip () 'aaaaaaaaaaaaa' >>>

极限与不等关系

Image
值得注意的是第三条里,即便当$a_{n}\leq b_{n}$的时候,最终$a=b$仍然是可能得,想想$\lim _{x\rightarrow +\infty }\dfrac {1} {x}=0$和$\lim _{x\rightarrow +\infty }\dfrac {2} {x}=0$ 感觉第三条比较常用,可以用来处理这个问题 http://math.stackexchange.com/questions/1131874/prove-without-method-of-contradiction-that-there-exists-a-real-number-less-than

通过完全由有理数构成的区间套来揭示无理数的存在

Image
本讲的前提是: For the time being, all quantities occurring are assumed to be rational numbers. 假设我们所知道的数只有有理数,还不知道无理数的存在。 这里说的null-sequence 是rational null-sequence ,定义如下 继续 the second class is empty的例子请看 https://en.wikipedia.org/wiki/Completeness_of_the_real_numbers#Nested_intervals_theorem 的Nested intervals theorem部分  

有理数的稠密性(The rational points are dense on the number axis.)

Image
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性。The rational points are dense on the number axis.   

$\int _{0}^{1}xdx=\dfrac {1} {2}$

$\int _{0}^{1}xdx=\dfrac {1} {2}$