Python calls other python scripts to call python scripts.
This example describes how to use python to call other python scripts. The specific method is as follows:
This instance calls the md5get. py script in the current directory. The Code is as follows:
Import OS import logging import subprocess log = logging. getLogger ("Core. analysis. processing ") INTERPRETER ="/usr/bin/python "if not OS. path. exists (INTERPRETER): log. error ("Cannot find INTERPRETER at path \" % s \". "% INTERPRETER) processor =" md5get. py "pargs = [INTERPRETER, processor] pargs. extend (["-- input = inputMd5s"]) subprocess. popen (pargs)
I hope this article will help you with Python programming.
How can I call other python scripts in a python script to run it?
If it is the same directory: import 1, 3, 5
If they are not added to the system variables first:
Import sys
Sys. path. append ('path \ 1 ')
Sys. path. append ('path \ 3 ')
Sys. path. append ('path \ 5 ')
Directly import
Another python script with parameters is called in the python script.
Cmd = '/home/menglin/androguard/androaxml. py-I {}| grep "android. permission. "'. format (path) p1 = subprocess. popen (cmd, stdout = subprocess. PIPE, shell = True)