beyond top level package error in relative import

后端 未结 13 2444
醉梦人生
醉梦人生 2020-11-22 12:50

It seems there are already quite some questions here about relative import in python 3, but after going through many of them I still didn\'t find the answer for my issue. s

13条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 13:07

    if you have an __init__.py in an upper folder, you can initialize the import as import file/path as alias in that init file. Then you can use it on lower scripts as:

    import alias
    

提交回复
热议问题