|
4.2.6 Examples
Simulating scanf()
Python does not currently have an equivalent to scanf(). Regular expressions are generally more powerful, though also more verbose, than scanf() format strings. The table below offers some more-or-less equivalent mappings between scanf() format tokens and regular expressions.
To extract the filename and numbers from a string like
you would use a scanf() format like
The equivalent regular expression would be
See About this document... for information on suggesting changes. |