在调用self对象时,本类调用用Win32Info().collect()

import platform

class Test:
def test(self):
func = getattr(self,platform.system().lower())
return func() #一定要返回func,不能func()

@staticmethod
def windows():
from plugins.collect_windows_info import Win32Info
return Win32Info().collect() #在调用self对象时,本类调用用Win32Info().collect()
@staticmethod
def linux():
return 'OK2'



ob = Test()
print(ob.test())
posted @ 2019-06-14 10:23  技术颜良  阅读(271)  评论(0编辑  收藏  举报