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:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiin8rEni6CsK5INSy2rVVzaamIKnLNqZwIqKjSptZqRPja21H3aBIhkV16_yP9QmGjgBZXa2rDH9Uys4dJ3vWUtk9NSOA4vuQhr89vVldb5u9zv1udP-zX9oAdgxnoOcG7UuwHGTtxg4o/s400/Capture.JPG)
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