最佳答案
In Perl I can do:
my ($x, $y) = split /:/, $str;
And it will work whether or not the string contains the pattern.
In Python, however this won't work:
a, b = "foo".split(":") # ValueError: not enough values to unpack
What's the canonical way to prevent errors in such cases?