像往常一样,我们可以直接复制文件到剪贴板简单的ctrl + c但我想用python来实现
ctrl + c
path = "..." def copy_file_to_clipboard() -> None: clipboard.copy_file(path) # this is a false code, but I want to know the code to do so
wmvff8tz1#
下面是在python 3.9(Notebook jupyter)中测试的解决方案:
import pyperclip as pc def copy_to_clipboard(file_name): with open(file_name, 'r') as f: text = f.read() pc.copy(text) print("File successfully copied to clipboard!") copy_to_clipboard('file.txt')
1条答案
按热度按时间wmvff8tz1#
下面是在python 3.9(Notebook jupyter)中测试的解决方案: