How to return data from one python file to another python file

I am using a python file. I want to call another python code. Is there a way with which I can return data from the second python code to call the python code. Any function like a function returns the value of the calling function.

-1
source share
2 answers

I must admit that I do not see the problem:

test1.py :

 def myfunc(): return "spam!" 

test2.py :

 import test1 print(test1.myfunc()) 

Output when running test2.py :

 spam! 
+1
source

Get everything into classes and functions and read a lot about importing modules

0
source

Source: https://habr.com/ru/post/1483676/


All Articles