即使模块位于我现在工作的同一目录中,我也无法导入模块(E:\Python Projekti\Python Crash Course)。我试图在这里找到解决方案,我以为我用 .module_name 找到了它,但它仍然不起作用。
我尝试了 .module_name 方法,它为我提供了包含所有可能模块的下拉菜单,但最后,它在终端中给了我一个错误。
from .restaurant_module import Restaurant
restaurant = Restaurant('Madera', 'Soulfood')
restaurant.describe_restaurant()
Traceback (most recent call last):
File "E:/Python Projekti/Python Crash Course/Chapter
9/imported_restaurant.py", line 1, in <module>
from .restaurant_module import Restaurant
ModuleNotFoundError: No module named '__main__.restaurant_module';
'__main__' is not a package