Python from question

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

I'm trying to import another package from For example,

When I'm like this, If you want to import domain.py from quiz.py

from context.domain import data

I know this is how you do it, but I don't know if you'll find a problem if I just tell you which one I'm missing When I do from context, the context does not appear as a keyword

python

2022-09-20 11:02

1 Answers

Although it belongs to the same dir, it is in different subdirectories, so you need to move the path.

dir
│
├ ├ a ━ aa.py
└ └ b ━ bb.py
# bb.py
from ..a.aa.py import aaa


2022-09-20 11:02

If you have any answers or tips


© 2022 pinfo. All rights reserved.