我是编程新手,我试图制作一个简单的程序来替换我复制的内容,当它的长度超过 10 个字符时,这是代码:
import pyperclip
import tkinter as Tk
while True:
r = Tk()
r.withdraw()
try:
selection = r.selection.get(selection="CLIPBOARD")
except tk.TclError:
selection = None
sleep(0.1)
try:
selection = r.selection.get(selection="CLIPBOARD")
except tk.TclError:
selection = None
r.clipboard_clear()
if len(result) > 10:
pyperclip.copy("aaa")
但它给了我这个错误:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'module' object is not callable
>>>
我知道这可能与 tkinter 模块有关,但我真的不知道它是什么或如何解决它。