HTuse HTuse
HTuse Python ·
8 steps

How to Call a Script in Python?

Step 1

Use `import script_name`

Step 2

Use `from script_name import function_name`

Step 3

Call a function with `function_name()`

Step 4

Run a script from another script with `subprocess.run(["python", "script_name.py"])`

Step 5

Execute a script file with `exec(open("script_name.py").read())`

Step 6

Use `runpy.run_path("script_name.py")`

Step 7

Call a script as a module with `python -m module_name`

Step 8

Use `os.system("python script_name.py")`