How to reference python package when filename contains a period

前端 未结 5 388
一生所求
一生所求 2020-12-03 02:51

I am using django and I have a file named models.admin.py and I want to do the following idea in models.py:

from \"models.admin\" import *

5条回答
  •  悲哀的现实
    2020-12-03 02:57

    No, you can't import a python file as a module if its name contains a period (or a question mark, or exclamation mark, etc). A python module's name (not including the .py) must be a valid python name (ie can be used as a variable name).

提交回复
热议问题