Python error: AttributeError: 'module' object has no attribute

前端 未结 4 1279
梦如初夏
梦如初夏 2020-11-29 07:15

I\'m totally new to Python and I know this question was asked many times, but unfortunately it seems that my situation is a bit different... I have created a package (or so

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 07:41

    The way I would do it is to leave the __ init__.py files empty, and do:

    import lib.mod1.mod11
    lib.mod1.mod11.mod12()
    

    or

    from lib.mod1.mod11 import mod12
    mod12()
    

    You may find that the mod1 dir is unnecessary, just have mod12.py in lib.

提交回复
热议问题