Using Standard Library Modules
You can import modules in your program to leverage their functionality. For instance, consider the sys
module in the Python standard library. Below is an example:
import sys
print("Command line arguments:", sys.argv)
When executed, this program prints the command line arguments provided to it. The sys.argv
variable holds these arguments as a list. For instance, running python module_using_sys.py we are arguments
results in sys.argv[0]
being 'module_using_sys.py'
, sys.argv[1]
being 'we'
, sys.argv[2]
being 'are'
, and sys.argv[3]
being 'arguments'
.