我正在尝试编写一个非常简单的键盘记录程序,但是当我运行该程序时,它引发了我无法解码的错误。 它说:ArgumentError:参数3:int太长,无法转换。我不明白为什么,我把我的key_presses参数(在这种情况下不是)转换为int,但是为什么不这样做呢?这是完整的错误回溯:https://gyazo.com/2995334b1859724df213e7e39033fc81
import keyboard
file = open("Tips.txt", "w")
keyboard_loop = True
while keyboard_loop is True:
if keyboard.is_pressed("a") or keyboard.is_pressed("ctrl + a"):
file.append("w")
if keyboard.is_pressed("b") or keyboard.is_pressed("ctrl + b"):
file.append("b")
if keyboard.is_pressed("c") or keyboard.is_pressed("ctrl + c"):
file.append("c")
if keyboard.is_pressed("d") or keyboard.is_pressed("ctrl + d"):
file.append("d")
if keyboard.is_pressed("e") or keyboard.is_pressed("ctrl + e"):
file.append("e")
if keyboard.is_pressed("f") or keyboard.is_pressed("ctrl + f"):
file.append("f")
if keyboard.is_pressed("g") or keyboard.is_pressed("ctrl + g"):
file.append("g")
if keyboard.is_pressed("h") or keyboard.is_pressed("ctrl + h"):
file.append("h")
if keyboard.is_pressed("i") or keyboard.is_pressed("ctrl + i"):
file.append("i")
if keyboard.is_pressed("j") or keyboard.is_pressed("ctrl + j"):
file.append("j")
if keyboard.is_pressed("k") or keyboard.is_pressed("ctrl + k"):
file.append("k")
if keyboard.is_pressed("l") or keyboard.is_pressed("ctrl + l"):
file.append("l")
if keyboard.is_pressed("m") or keyboard.is_pressed("ctrl + m"):
file.append("m")
if keyboard.is_pressed("n") or keyboard.is_pressed("ctrl + n"):
file.append("n")
if keyboard.is_pressed("o") or keyboard.is_pressed("ctrl + o"):
file.append("o")
if keyboard.is_pressed("p") or keyboard.is_pressed("ctrl + p"):
file.append("p")
if keyboard.is_pressed("q") or keyboard.is_pressed("ctrl + q"):
file.append("q")
if keyboard.is_pressed("r") or keyboard.is_pressed("ctrl + r"):
file.append("r")
if keyboard.is_pressed("s") or keyboard.is_pressed("ctrl + s"):
file.append("s")
if keyboard.is_pressed("t") or keyboard.is_pressed("ctrl + t"):
file.append("t")
if keyboard.is_pressed("u") or keyboard.is_pressed("ctrl + u"):
file.append("u")
if keyboard.is_pressed("v") or keyboard.is_pressed("ctrl + v"):
file.append("v")
if keyboard.is_pressed("w") or keyboard.is_pressed("ctrl + w"):
file.append("w")
if keyboard.is_pressed("x") or keyboard.is_pressed("ctrl + x"):
file.append("x")
if keyboard.is_pressed("y") or keyboard.is_pressed("ctrl + y"):
file.append("y")
if keyboard.is_pressed("z") or keyboard.is_pressed("ctrl + z"):
file.append("z")