0

I have a program that have arguments are 3 files: 2pdf and 1 txt. I enter it on console with hands.

path_text = input("Enter path to text file ")
path_pdf_first = input("Enter path to fist pdf file ")
path_pdf_second = input("Enter path to second pdf file ")

How i can use this programm from cmd like this

python program.py *path1* *path2* *path3* 

Instead with hands and "Enter" again and again

Immersion
  • 171
  • 5

1 Answers1

1

Use sys.argv to take parameter using cmd

import sys
path_text = sys.argv[1] # parameter number 1
path_pdf_first = sys.argv[2] # parameter number 2
path_pdf_second = sys.argv[3] # parameter number 3

Note:

sys.argv[0] is the name of the script

sachin dubey
  • 755
  • 9
  • 28