other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
other:python:misc_by_jyp [2021/07/06 13:25] – Started the command-line args section jypeter | other:python:misc_by_jyp [2021/07/06 13:49] – [Using command-line arguments] added getopt, optparse and argparse jypeter | ||
---|---|---|---|
Line 41: | Line 41: | ||
==== Using command-line arguments ==== | ==== Using command-line arguments ==== | ||
- | === The fast but non-flexible way === | + | === The extremely easy but non-flexible way: sys.argv |
The name of a script, the number of arguments (including the name of the script), and the arguments (as strings) can be accessed through the '' | The name of a script, the number of arguments (including the name of the script), and the arguments (as strings) can be accessed through the '' | ||
Line 62: | Line 62: | ||
1 tas | 1 tas | ||
2 tas_tes.nc</ | 2 tas_tes.nc</ | ||
+ | |||
+ | === The C-style way: getopt === | ||
+ | |||
+ | Use [[https:// | ||
+ | |||
+ | === The deprecated Python way: optparse === | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | === The current Python way: argparse === | ||
+ | |||
+ | [[https:// | ||
/* | /* |
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter