gpt4 book ai didi

python - 如何修复此与 Python 中的模块相关的错误?

转载 作者:行者123 更新时间:2023-12-03 08:24:27 25 4
gpt4 key购买 nike

错误信息:

keyboard.py", line 6, in <module>
keyboard.write("GEEKS FOR GEEKS\n")
AttributeError: module 'keyboard' has no attribute 'write'
Press any key to continue . . .
我也尝试过升级pip并重新安装键盘模块......
我的代码是(来源: GEEKSFORGEEKS)
#Using Keyboard module in Python
import keyboard

# It writes the content to output
keyboard.write("GEEKS FOR GEEKS\n")


# It writes the keys r, k and end of line
keyboard.press_and_release('shift + r, shift + k, \n')
keyboard.press_and_release('R, K')

# it blocks until ctrl is pressed
keyboard.wait('Ctrl')

最佳答案

如果您已将正在执行的脚本命名为 keyboard.py,它将与您尝试导入的模块发生冲突。
尝试简单地更改您尝试运行的脚本的名称。

关于python - 如何修复此与 Python 中的模块相关的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64731352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com