Call a function from another file?

前端 未结 17 2603
梦谈多话
梦谈多话 2020-11-22 08:06

Set_up: I have a .py file for each function I need to use in a program.

In this program, I need to call the function from the external files.

I\'ve tried:

17条回答
  •  情深已故
    2020-11-22 08:45

    append a dot(.) in front of a file name if you want to import this file which is in the same directory where you are running your code.

    For example, i'm running a file named a.py and i want to import a method named addFun which is written in b.py, and b.py is there in the same directory

    from .b import addFun

提交回复
热议问题