July 2009
Intermediate to advanced
744 pages
20h 2m
English
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 pickle module.
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[0] contains the name of the script being executed. Writing an error message ...
Read now
Unlock full access