新手,一般都需要执行以下命令,用来导入对应模块
pip install -i Simple Index pynput
键盘win+r进入输入cmd
执行该命令即可:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pynput
打开pycharm,输入代码如下
from pynput.keyboard import Key,Controller
import timekeyboard = Controller()
a=input("请输入你需要循环输出的内容")
b=eval(input('请输入你要循环输出的次数:'))
print("数据已接收!请将光标移动到会话框")
time.sleep(2)
for i in range(3):print(r'距离程序运行结束还有%d秒!'%(3-i))time.sleep(1)
for i in range(b):keyboard.type(a)keyboard.press(Key.enter)keyboard.release(Key.enter)time.sleep(0.1)
print('消息发送完成!请关闭窗口')