gpt4 book ai didi

python - 导入带有 "space"字符的 python 模块目录

转载 作者:行者123 更新时间:2023-12-01 08:01:35 25 4
gpt4 key购买 nike

我想导入当前文件目录中名为 DataGenerator 的类:

/content/gdrive/My Drive/mrcnn_fire/ssd/python_files/object_detection_2d_data_generator.py

我的导入方式如下:

from content.gdrive.My Drive.mrcnn_fire.ssd.python_files.object_detection_2d_data_generator import DataGenerator

它给了我以下错误:

File "<ipython-input-3-7d861f8abbeb>", line 4
from content.gdrive.My Drive.mrcnn_fire.ssd.python_files.object_detection_2d_data_generator import DataGenerator
^
SyntaxError: invalid syntax

最佳答案

你也可以尝试这样:

# object_detection_2d_data_generator.py
import sys
sys.path.insert(0, '/content/gdrive/My Drive/mrcnn_fire/ssd/python_files')

from object_detection_2d_data_generator import DataGenerator

关于python - 导入带有 "space"字符的 python 模块目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55709031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com