1、__unicode__、__str__
在Django中,如果用的是Python3的话就只能用__str__方法,如果是Python2的话就使用__unicode__方法。。这个__str__的作用是美化打印出来的结果
2、url path 前者是2.x 后者是3.X
3、Context、RequestContext
render_to_response与RequestContext结合使用,Context和vendor使用,用来渲染模板。
4、print 在 Python3.x 是一个函数,但在 Python2.x 版本不是一个函数,只是一个关键字。
5、不等运算符
Python 2.x中不等于有两种写法 != 和 <>
Python 3.x中去掉了<>, 只有!=一种写法
6、去掉了repr表达式``
Python 2.x 中反引号``相当于repr函数的作用
Python 3.x 中去掉了``这种写法,只允许使用repr函数,这样做的目的是为了使代码看上去更清晰么?不过我感觉用repr的机会很少,一般只在debug的时候才用,多数时候还是用str函数来用字符串描述对象。
def sendMail(from_: str, to: str, title: str, body: str) -> bool:
pass