I have looked at this solution but my requirements are slightly different.
I have a string of the form: "command int1 int2"
, e.g. "download 600 10"
.
I know I could use str.split(" ")
to break the string into its component parts but then I would have to convert the 2nd and 3rd parameters to int
s. Thus the following won't work (the int
cast fails when it encounters "download"
in the string):
(cmd, int1, int2) = [int(s) for s in file.split(' ')]
I'm still pretty new to Python... so I'm wondering if there is a nice, pythonic way to accomplish my goal?