使用“空格”字符导入 python 模块目录

我想在当前文件目录中导入一个名为 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


MYYA
浏览 177回答 2
2回答

Qyouu

你也可以这样尝试:# object_detection_2d_data_generator.pyimport syssys.path.insert(0, '/content/gdrive/My Drive/mrcnn_fire/ssd/python_files')from object_detection_2d_data_generator import DataGenerator

杨魅力

您可以通过以下方式导入它:DataGenerator&nbsp;=&nbsp;__import__("content/gdrive/My&nbsp;Drive/mrcnn_fire/ssd/python_files/object_detection_2d_data_generator/DataGenerator")
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go