我无法将.py文件导入另一个.py文件。我以为
from .filename import *
但是我总是收到ModuleNotFoundError
我也尝试过:
from filename import *
from .filename import Class
from . import filename
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
我也尝试添加
.
├── __pycache__
│ └── model.cpython-36.pyc
├── ai.py
├── model.py
└── recording
├── openaigym.video.0.2641.video000000.meta.json
└── openaigym.video.0.2641.video000000.mp4
但是那也不起作用。
你们会看到我想念的吗?
只需澄清一下:
这是结构
POST collection/_bulk?filter_path=_
{"index":{}}
{"items":[{"id":11,"time_added":"2017-08-07T09:07:15.000Z","condition":"fair"},{"id":13,"time_added":"2019-08-07T09:07:15.000Z","condition":"good"},{"id":14,"time_added":"2016-08-07T09:07:15.000Z","condition":"poor"}]}
{"index":{}}
{"items":[{"id":21,"time_added":"2017-09-07T09:07:15.000Z","condition":"fair"},{"id":23,"time_added":"2019-09-07T09:07:15.000Z","condition":"good"},{"id":24,"time_added":"2016-09-07T09:07:15.000Z","condition":"poor"}]}
{"index":{}}
{"items":[{"id":31,"time_added":"2017-10-07T09:07:15.000Z","condition":"fair"},{"id":33,"time_added":"2019-10-07T09:07:15.000Z","condition":"good"},{"id":34,"time_added":"2016-10-07T09:07:15.000Z","condition":"poor"}]}
{"index":{}}
{"items":[{"id":41,"time_added":"2017-11-07T09:07:15.000Z","condition":"fair"},{"id":43,"time_added":"2019-11-07T09:07:15.000Z","condition":"good"},{"id":44,"time_added":"2016-11-07T09:07:15.000Z","condition":"poor"}]}
{"index":{}}
{"items":[{"id":51,"time_added":"2017-12-07T09:07:15.000Z","condition":"fair"},{"id":53,"time_added":"2019-12-07T09:07:15.000Z","condition":"good"},{"id":54,"time_added":"2016-12-07T09:07:15.000Z","condition":"poor"}]}
感谢您的帮助!
答案 0 :(得分:0)
如果您的类名与任何现有的python类冲突,则可能会发生这种情况
在您的ai.py
文件中:
from model import Class_name
如果这仍然行不通,请在拥有__init.py__
和model.py
的目录中添加一个空的ai.py
文件。
注意:有时VSCode会显示unresolved imports
警告,即使您的代码运行正常。