2016-02-28 132 views
0

我想用python編寫一個腳本,它需要一個in.txt文件,並獲取每一行復制並粘貼到某個座標,然後單擊某個座標。複製和粘貼自動化

是否有任何模塊可以幫助我完成這項自動化任務?

這裏是我的僞代碼:

-get in file 

-put lines into array 

-for each line in the array 

{ 
    copy it 
    paste to a certain coordinate 
    click a certain coordinate 
} 
+0

貼在那裏,點擊某一座標還不是很清楚。你究竟想用文件的內容來做什麼? –

回答

0

如果要複製到剪貼板,並讓腳本處理將剪貼板中的線的提取,你可以看看pyperclip模塊。

但對於你的情況,你爲什麼不只是使用內置的功能,如

fileName = open(urlToFile) 
fileNameContentString = fileName.read() #return a string of entire content 
#or 
fileNameContentList = fileName.readlines() #return a list of string of each line 
#finally don't forget to close 
fileName.close() 

for line in fileNameContentList: 
    print line 
    # whatever else you would like to do with the line.