且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从剪贴板获得格式的内容

更新时间:2022-10-15 13:26:39

剪贴板确实包含多种格式的数据。通常,您已获得TEXT / UnicodeText,RTF和HTML。

请参阅 MSDN标准格式列表。和 HTML格式


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. :)

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.