We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

Is there a scanf() or sscanf() equivalent?

Not as such.

For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the split method of string objects and then convert decimal strings to numeric values using int or float. split supports an optional separator parameter which is useful if the line uses something other than whitespace as a separator.

For more complicated input parsing, regular expressions are more powerful than C’s sscanf() and better suited for the task.

CATEGORY: programming