python3 操作windows的粘贴板(读取和传值)

#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = "loki"

import win32con
import win32clipboard as wincld


def get_text():
    wincld.OpenClipboard()
    text_result = wincld.GetClipboardData(win32con.CF_UNICODETEXT)
    wincld.CloseClipboard()
    return text_result


def set_text(info):
    wincld.OpenClipboard()
    wincld.EmptyClipboard()
    wincld.SetClipboardData(win32con.CF_UNICODETEXT, info)
    wincld.CloseClipboard()


# set clipboard
set_text('loki_demo')

# read clipboard
print(get_text())

 

转载于:https://www.cnblogs.com/Cong0ks/p/9223841.html

你可能感兴趣的:(python3 操作windows的粘贴板(读取和传值))