Open main menu

CDOT Wiki β

Changes

OPS435 Python3 Lab 2

66 bytes added, 13:25, 12 September 2019
PART 2 - Command line arguments
:#Use a temporary file for testing your work for this section.
:#In order to read access command line arguments in Python, we will need to use a special python object called '''sys.argv''' from the '''sys''' module. We can use the python keyword '''import''' to load the '''sys''' module so that we can access it in our python script. '''sys.argv''' is a list object which is used to hold everything given at the command line, including the command itself. The '''sys''' module is one of the built-in modules come comes with the Python interpreter. By issuing the '''import sys'''statement at the top of a python script, you have loaded it will load the code written by another other person, each 'library' (or 'module') that gets loaded will give us extra functionality and objects to our python script.<br><br>
:#Start with the following line to import additional python objects:<source>
import sys
1,760
edits