问题
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. :)
回答1:
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.
回答2:
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/
来源:https://stackoverflow.com/questions/9630235/how-to-get-content-with-format-from-clipboard