how to pass arguments to python script from bash

Solutions on MaxInterview for how to pass arguments to python script from bash by the best coders in the world

showing results for - "how to pass arguments to python script from bash"
Luis
22 Feb 2019
1>> python script.py var1 var2
2
3import sys 
4
5# contains the script name
6sys.argv[0]
7
8# contains the first variable (var1)
9sys.argv[1] 
10
11# contains the second variable (var2)
12sys.argv[2]