python pynput循环中的此代码循环有什么问题缩进错误

时间:2018-09-27 08:00:05

标签: python while-loop

7.0,我想知道这段代码做错了什么。我想让它无限循环并说vcmine start,但我已经尝试了一段时间,并尝试了一遍又一遍地发送代码,我只希望它将此代码打印到游戏中,这样我就不必在我的电脑上,但是我只能让它工作,只能说一次,请帮助我出了点问题,我不知道什么

from pynput.keyboard import Key, Controller
import time

keyboard = Controller ()

while True:
for char in "vcmine start":
    keyboard.press(char)
    keyboard.release(char)
    time.sleep(0.03)
    break
while True:
    keyboard.press(key.enter)
    keyboard.press(key.enter)
    break

1 个答案:

答案 0 :(得分:0)

我认为您想要的是:

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

while True:
    for char in "vcmine start":
        keyboard.press(char)
        keyboard.release(char)
        time.sleep(0.03)
    keyboard.press(key.enter)
    time.sleep(0.03)
    keyboard.press(key.enter)
    time.sleep(0.03)