如何从剪贴板获得格式的内容 [英] How to get content with format from clipboard

查看:171
本文介绍了如何从剪贴板获得格式的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我使用Chrome从互联网复制一些单词并粘贴到Office单词时,单词提醒我可以粘贴保留源格式的单词。 br>
那意味着剪贴板可以同时包含纯文本和它的格式吗?

我正在使用Python编写一个应用程序来获取剪贴板的内容。但不知道如何获取内容格式。

  import Tkinter 

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

顺便提一下,我的应用程序正在运行在Win7上。



:)

解决方案

剪贴板确实包含多种格式的数据。通常,您已获得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.

这篇关于如何从剪贴板获得格式的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆