Python – How to read/process command line arguments

command-linecommand-line-argumentspython

I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments.

What are some of the ways Python programmers can do this?

Related

Best Solution

import sys

print("\n".join(sys.argv))

sys.argv is a list that contains all the arguments passed to the script on the command line. sys.argv[0] is the script name.

Basically,

import sys
print(sys.argv[1:])