__module__,__class__

table of Contents

# lib/aa.py
class C:
    def __init__(self):
        self.name = 'SB'
# index.py

from lib.aa import C

obj = C()

__module__

  • __module__ indicate the current operation of the object in that module
print(obj.__module__)  # 输出 lib.aa,即:输出模块

__class__

  • What __class__ object representing the current operation of the class is
print(obj.__class__)  # 输出 lib.aa.C,即:输出类

Guess you like

Origin www.cnblogs.com/nickchen121/p/10991513.html