how to get the spesific line of the text in the clipboard

Tim Chase python.list at tim.thechases.com
Tue May 19 12:18:41 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?
> [snip]
> 
> Split the string into lines and take the eighth line (at index 7). I've
> limited the number of splits to 8 because I'm not interested in any of
> the following lines:
> 
>      line = text.split("\r\n", 8)[7]

Strings have a .splitlines() method that makes this a little more 
elegant:

   line = text.splitlines()[7]

-tkc







More information about the Python-list mailing list