5

guys.

When i copy some words from internet using Chrome and paste to the Office Words, Words remind me that I can paste the words keeping source format.
That means clipboard can contain both the plain text and its format?

Meanwhile, I am writing an app using Python to get the content of clipboard. But don't know how to get the content format.

import Tkinter

if __name__ == '__main__':
    r=Tkinter.Tk()
    r.withdraw()
    print r.clipboard_get()
    r.destroy()

BTW, my app is running on Win7.

Thanks in advance. :)

Johnny
  • 51
  • 1
  • 3

2 Answers2

2

The clipboard does contain data in multiple formats. Typically, you've got TEXT/UnicodeText, RTF, and HTML.
See MSDN List of standard formats. and HTML Format.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
-1

I suggest to don't write your own tool when there are existing modules doing the same. Try: http://coffeeghost.net/2010/10/09/pyperclip-a-cross-platform-clipboard-module-for-python/

marbdq
  • 1,235
  • 8
  • 5