how to get the spesific line of the text in the clipboard
MRAB
google at mrabarnett.plus.com
Tue May 19 12:34:57 EDT 2009
Tim Chase wrote:
>>> 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]
>
I thought it split only on "\n". Turns out it can handle "\r\n" too!
Yay! :-)
More information about the Python-list
mailing list