我正在尝试编写一个简单的程序,该程序将允许我控制数组中数字 5 的位置。但是,当我运行代码时,控件并没有真正起作用。另外,我正在尝试清除终端,以便它只显示当前位置,而不是过去的位置,但即使这样也不起作用。请帮忙。
import numpy as np
import keyboard
from os import system
a = int(input())
c = int(input())
z = 0
isKEYPRESSED = 0
while (True):
b = np.zeros((a,c))
for i in range(a):
for j in range(c):
b[i][j]=0
b[z][0] = 5
print(b)
if keyboard.read_key() =="right" and isKEYPRESSED == 0:
b[z][0] = 0
z = z + 1
isKEYPRESSED = 1
if keyboard.read_key() =="right" and isKEYPRESSED == 1:
isKEYPRESSED = 0
if keyboard.read_key() =="left" and isKEYPRESSED == 0:
b[z][0] = 0
z = z - 1
isKEYPRESSED = 1
if keyboard.read_key() =="left" and isKEYPRESSED == 1:
isKEYPRESSED = 0
system('clear')