As the title says, it will be updated at any time
Import an external file (.py is not required) ↓ Get variables in the form of "external file.variables in external file"
variable.py
number = 15
array = [3,4,5]
array_2 = [[1,2],[3,4],[5,6]]
main.py
import variable
print(variable.number)
print(variable.array)
print(variable.array_2)
result
15
[3,4,5]
[[1,2],[3,4],[5,6]]
External file functions can be used in the form of "from external file import function you want to use"
scalarMultiplication.py
#A function that just multiplies a by b
def multi(a,b):
return a*b
main.py
from scalarMultiplication import multi
multi(2,3)
#6 Execution result
Available in the form of "from external file import class you want to use"
Recommended Posts