Question #232183 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/232183
Status: Open => Answered
RaiMan proposed the following answer:
as a convention and saving some computing resources: all imports should
be at the beginning of your script
This would be a (recommended ;-) more generalized version of the
function and it returns a number:
def getValue( text ):
m = re.match("[^0-9]*([0-9]*\.?[0-9]*)", text)
try:
return m.group(1) # returns the found value
except:
return -1 # returns -1 if any problems
usage:
balance = "USD30000.00" # as read by the previous region.text() function
bval = getValue(balance)
print "balance-text:", balance, "balance-value", bval
your case even shorter:
balance = getValue( find().text() )
# now balance already is a numeric value
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp