how to get the spesific line of the text in the clipboard
zhouhaifeng
mypromise at sina.com
Tue May 19 11:30:50 EDT 2009
I want to get the eighth line in the text of the text in the clipboad,
but when I call GetClipboardData
I only get a string, how can I repair it?
thanks a lot.
My code is here :
try:
win32clipboard.OpenClipboard(hWnd)
#win32api.Sleep(500)
text = win32clipboard.GetClipboardData(win32con.CF_TEXT)
#win32clipboard.EmptyClipboard()
win32clipboard.CloseClipboard()
logging.info(len(text))
return text
except Exception, exc:
logging.info(exc)
...
def get_file_title(filename):
f = file(filename)
#f = open(filename, encoding='gb2312', mode='w+')
title = u""
line_count = 0
for line in f:
line_count = line_count + 1
if line_count == 8:
<----------------------------now I write the text of the clipboard into
file, and then read it from file, at this time, I can get line 8 , but
it so low efficiency
title = unicode(line, 'gb2312', 'ignore')
title = title.replace("\r\n", '')
break
return title
More information about the Python-list
mailing list