Categories
Python Answers

How to access command line arguments with Python?

Spread the love

Sometimes, we want to access command line arguments with Python.

In this article, we’ll look at how to access command line arguments with Python.

How to access command line arguments with Python?

To access command line arguments with Python, we can use the sys.argv property.

For instance, we write

import sys

print(sys.argv)

to print out all the command line arguments in a list with print and sys.argv.

Conclusion

To access command line arguments with Python, we can use the sys.argv property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *