[1.1.4] Region.text(): adds new-line at the end of the recognized string

Asked by Linda on 2019-05-08

My code:
    a = find("1557282546849.png").text()
    b = "64"
    print a
    print "--"
    print b
    if a == b:
        print 'pass'
    else:
        print 'diff'

Result:
64

--
64
diff

How to do with no empty string?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-05-08
Last query:
2019-05-08
Last reply:
2019-05-08
Best RaiMan (raimund-hocke) said : #1

ok, seems to be some weird behavior:
it is not an empty string, but a new-line, that is added to the "64"

I have to check.

workarounds:

use
a = find("1557282546849.png").text().strip()
... which removes whitespace from start and end of string

or
a = find("64.png").collectWordsText()[0]
... see: https://sikulix-2014.readthedocs.io/en/latest/region.html#extracting-text-from-a-region

Linda (kkea55534) said : #2

Thanks RaiMan, that solved my question.