• Skip to primary navigation
  • Skip to content
  • Skip to footer
michael harty
  • Posts
  • Tags
  • About
  • TIL
    Michael Harty

    Michael Harty

    I’m a geologist learning and using data science. Read about my projects and the things I’m learning.

    • Denver, CO :mountain:
    • GitHub
    • Twitter
    • LinkedIn

    Using command line arguments when running a python script (python)

    When running a Python script from the command line, you can pass arguments separated by spaces.

    python script.py arg1 arg2

    To access the arguments in the script, use the sys module.

    sys.argv is a list of command line arguments where the first element (sys.argv[0]) is the name of the script.

    Tutorials Point

    Updated: October 30, 2023

    Previous Next
    • GitHub
    • Twitter
    • LinkedIn
    • Feed
    © 2023 michael harty. Powered by Jekyll & Minimal Mistakes.