4

Python零散的小知识点 | Kerry

 2 years ago
source link: https://yuansuixin.github.io/2018/03/30/tornado-session-py/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Python零散的小知识点 | Kerry

Python零散的小知识点

  • 注意:本节小知识点都是为tornado自定义session准备的!

  • 多继承是先执行左边的,再依次向右,继承的一些知识点,太过基础了,这里我就不赘述了

  • super是按照顺序查找,也可以不让他按顺序查找,就是使用类名.方法名(self)
  • obj = Foo()
    obj.f1()
    上面是对象自动将对象本身传递给方法,我们也可以手动的传递,就相当于
    obj = Foo()
    Foo.f1(obj)
  • self是什么?self永远是调用这个方法的对象,

  • 使用session[‘xx’]=’fdas’这种键值方式的语法,Python就会自动调用__setitem()__魔法方法,也就是说并不是只有字典可以使用键值的方式调用,所有类都可以,只是加上这个对应的魔法方法即可

  • Python中的in操作符的时候会自动调用__contains__()魔法方法


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK