How to call variable in type or paste methods?

Asked by Sreekanth

I am trying to call variable through type or paste methods, whose values need to be pasted or typed on to the text fields.
eg: f=open('C:/folder/filename.txt')
f.read(1)
type/paste (f.read(1))
are there any specific indentions to call variables in type/paste methods?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Sreekanth
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Since I am RaiMan, I have to say:
This is basic Python scripting (if you want to do more complex stuff, you have to learn the basics).
Have a look at the docs.

But since I am RaiMan, I give you some start ;-)

f=open('C:/folder/filename.txt')
var = f.read(1) # reads one byte (empty string at eof)
# var = f.read() # var contains the whole file content
# var = f.readline() # var contains the next line incl. line end
# var = f.readlines() # var is a list and contains all lines
paste(var)

to further process var after reading use the string functions like strip(), split(), ...

The basic file operations expect plain ASCII files. If file content is UTF-8 coded, you have to use the respective codec.

Revision history for this message
Sreekanth (sreekanth-challa27) said :
#2

This helps, i'll explore in to other stuff too. Thanks a ton Raiman.