# lib/aa.py
class C:
def __init__(self):
self.name = 'SB'
# index.py
from lib.aa import C
obj = C()
print(obj.__module__) # 输出 lib.aa,即:输出模块
a = __import__('sys')
print(a.path)
print(obj.__class__) # 输出 lib.aa.C,即:输出类
print(obj.__class__.__name__) # 输出 C,即:输出类名
原文:https://www.cnblogs.com/randysun/p/12252925.html