We will see how to call one python script in another python
script with a simple example below
Python script 1:
t1.py
The above script will print the value of "a"
The output of python script 1:
To use this python script in another python script:
Use import package to import the python script in another script as below
t2.py
In the above script
import t1: will import the python script in t1.py to t2.py
b = str(t1.a): will initialize the output of t1.py to the variable "b"
print (b): Prints the value of "b"
The output of python script 2:
Displaying the output of both python scripts.
script with a simple example below
Python script 1:
t1.py
The above script will print the value of "a"
The output of python script 1:
To use this python script in another python script:
Use import package to import the python script in another script as below
t2.py
In the above script
import t1: will import the python script in t1.py to t2.py
b = str(t1.a): will initialize the output of t1.py to the variable "b"
print (b): Prints the value of "b"
The output of python script 2:
Displaying the output of both python scripts.
No comments:
Post a Comment