How to import the class within the same directory or sub directory?

后端 未结 13 1202
醉梦人生
醉梦人生 2020-11-22 06:34

I have a directory that stores all the .py files.

bin/
   main.py
   user.py # where class User resides
   dir.py # where class Dir resides
         


        
13条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 06:47

    I'm not sure why this work but using Pycharm build from file_in_same_dir import class_name

    The IDE complained about it but it seems it still worked. I'm using Python 3.7

提交回复
热议问题