【发布时间】:2021-02-20 04:11:43
【问题描述】:
错误信息:
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并重新安装键盘模块......
MY CODE 是(来源: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')
【问题讨论】:
-
你的操作系统是什么?我不确定在 windows 和 mac 但 linux 不允许你使用 keyboard.write() 除非你有管理员权限
标签: python module keyboard syntax-error