Python写入并访问剪切板

来源:https://stackoverflow.com/questions/101128/how-do-i-read-text-from-the-windows-clipboard-from-python

import win32clipboard as w


def setText(text="English testing, 中文测试"):
	# set clipboard data
	w.OpenClipboard()
	w.EmptyClipboard()
	w.SetClipboardText(text)
	w.CloseClipboard()

def getText():
	# get clipboard data
	w.OpenClipboard()
	data = w.GetClipboardData()
	w.CloseClipboard()
	return data



setText(text="English testing, 中文测试...")
print([getText()])



你可能感兴趣的:(Python写入并访问剪切板)