导入“ pynput.keyboard”无法从源塔(Report Missingimports)中解析

发布于 2025-01-31 10:59:16 字数 893 浏览 4 评论 0 原文

我正在尝试编写一些代码,这些代码本质上是键入随机5个字符词。 我无法获得pynput.keyboard工作,因为我继续收到相同的错误消息(导入“ pynput.keyboard”无法从源头解决) 我的代码:

from pynput.keyboard import Key,Controller
keyboard = Controller()
from random import randrange
import time


alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
word = []

for i in range(5):
    x = randrange(1,26)
    #rint(x)
    l1 = alphabet[x-1]
    #print(l1)
    word.append(l1)

y = ''.join(word)
time.wait(5)
keyboard.press(y)
keyboard.release(y)

我已经做过的

pip3 install pynput

问题似乎与我发现的这个相似。

I am trying to write some code that essentially types a random 5 character word.
I can't get pynput.keyboard to work as I keep getting the same error message (Import "pynput.keyboard" could not be resolved from source)
my code:

from pynput.keyboard import Key,Controller
keyboard = Controller()
from random import randrange
import time


alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
word = []

for i in range(5):
    x = randrange(1,26)
    #rint(x)
    l1 = alphabet[x-1]
    #print(l1)
    word.append(l1)

y = ''.join(word)
time.wait(5)
keyboard.press(y)
keyboard.release(y)

I already did

pip3 install pynput

My problem seems to be similar to this one that I found. https://www.reddit.com/r/learnpython/comments/jqepj8/i_think_python_hates_me_import_pynputmouse_could/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文