9. Input and Output
This chapter describes the basics of Python input and output (I/O), including command-line options, environment variables, file I/O, Unicode, and how to serialize objects using the
Reading Command-Line Options
When Python starts, command-line options are placed in the list
sys.argv. The first element is the name of the program. Subsequent items are the options presented on the command line after the program name. The following program shows a minimal prototype of manually processing simple command-line arguments:
In this program,
sys.argv contains the name of the script being executed. Writing an error message ...