sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10062
Re: [Question #194165]: get lines (not characters) from clipboard
Question #194165 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/194165
RaiMan proposed the following answer:
xReader = Env.getClipboard()
for line in xReader:
print line
lets look at it step by step:
- xReader contains a string as result from Env.getClipboard()
- a string is a list of characters
- for x in aList: loops through the list setting x to every list element one after the other
conclusion:
since xReader is a list of characters, the loop produces one printout for each character.
If you expect "lines" to be in your string coming from the clipboard,
they should have some line breaks (e.g. \n), that can be used to split
the string into "lines":
# we expect \n as line break
xReader = Env.getClipboard()
for line in xReader.split("\n"):
print line
will do what you want, even if it is only one line without the line
break.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.