1. Call in the original file
DEF ABC (X, Y): Print X + Y ABC ( 2,3) # brackets directly call parameter passing Function Name
2. The functions of different files the same package (package) The following call
""" Basics(package) --->AAAA.py """ def add(x,y): return x + y
"" " Basics (Package) ---> BBBB.py " "" # method. 1 Import AAAA # first import module AAAA Print AAAA.add (1,2) # and then add the called function module AAAA () # Method 2 from AAAA import add # to add import function module AAAA Print add (2,3) # re-use function calls the method name
3. The function call in different packages (package)
""" common(package) --->AAAA.py """ def add(x,y): return x + y
""" Basics(package) --->BBBB.py """ #方法1 from common.AAAA import add print add(2,3) #方法2 import python_API.AAAA print python_API.AAAA.add(2,3)