PYTHON get files from command line
Using argparse is quite intuitive:
import argparseparser = argparse.ArgumentParser() parser.add_argument("--file", "-f", type=str, required=True)args = parser.parse_args()
Now the name of the file is located in:
args.file
You just have to run the program a little differently:
python code.py -f input.txt