Skip to content

Commit 2747c35

Browse files
author
tuntun
committed
Python 的cls
1 parent ef9c484 commit 2747c35

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

cls.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Python 的cls
4+
5+
class demo(object):
6+
def foo(cls):
7+
print(dir(cls))
8+
9+
demo = demo()
10+
demo.foo()
11+
12+
"""
13+
demo.foo()输出的结果跟dir(demo)的结果一样:
14+
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof_
15+
_', '__str__', '__subclasshook__', '__weakref__', 'foo']
16+
"""

0 commit comments

Comments
 (0)