Call a function from another file?

前端 未结 17 2609
梦谈多话
梦谈多话 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条回答
  •  萌比男神i
    2020-11-22 09:11

    Inside MathMethod.Py.

    def Add(a,b):
       return a+b 
    
    def subtract(a,b):
      return a-b
    

    Inside Main.Py

    import MathMethod as MM 
      print(MM.Add(200,1000))
    

    Output:1200

提交回复
热议问题