sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #05091
Re: [Question #170179]: How compare text from a region and integer
Question #170179 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/170179
Status: Open => Answered
RaiMan proposed the following answer:
if you do it this way, either n must be a string or m must be a number.
1. both as string:
n= "73"
if m==n:
print "exact match"
else:
print "found something else"
2. both as number:
m =int(r.text())
n= 73
if m==n:
print "exact match"
else:
print "found something else"
comment on 1:
this might still fail, since m might contain characters that are not visible when printed.
so you might use:
if m.count(n) > 0:
this looks for the string n in m.
comment on 2:
this might fail, if m cannot be converted to an integer, because the string not only contains digits.
You might use a regex, to get the number
import re
m = r.text()
re.match(".*(\d*?)", m)
mn = int(re.group(1)) if re.group(1) else Null
if mn and mn == n:
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.