51.python的包的创建与使用

employee就是包

 导入包,使用时默认调用__init__.py文件

class Employee:
    __wwid = ''  # 两个__下划线表示private私有变量
    __name = ''
    wwid = 'cd987' # public公有变量

    def set_wwid(self, wwid2):
        self.__wwid = wwid2
        # print('__wwid_module:', self.__wwid)

    def get_wwid(self):
        # print('__wwid_module_get:',self. __wwid)
        return self.__wwid
class Employee_task:
    __run = ''
    __walk = ''

    def set_run(self, run2):
        self.__run = run2

    def set_walk(self, walk2):
        self.__walk = walk2

    def get_run(self):
        return self.__run

    def get_walk(self):
        return self.__walk

task.py

class Employee_task:
    __run = ''
    __walk = ''

    def set_run(self, run2):
        self.__run = run2

    def set_walk(self, walk2):
        self.__walk = walk2

    def get_run(self):
        return self.__run

    def get_walk(self):
        return self.__walk

 

使用方法:

main.py

 

 

 

posted @ 2024-01-07 21:18  txwtech  阅读(7)  评论(0编辑  收藏  举报