[英]How to fix this Error related to Modules in Python?
错误信息:
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,它将与您尝试导入的模块发生冲突。 尝试简单地更改您尝试运行的脚本的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.