Te sugerimos que revises esta solución en un entorno controlado antes de pasarlo a producción, saludos.
Ejemplo 1: mover el cursor en python
import sys
defwrite(string:str, flush:bool=True)->None:
sys.stdout.write(string)if flush:
sys.stdout.flush()# up: x1b[nA# down: x1b[nB# right: x1b[nC# left: x1b[nD# have you noticed that in python when you hit use the arrow# keys in an input, you get this weird output?# ^[[A# ^[[B# ^[[C# ^[[D# now you'll understand why. when you type something an input,# it literally just prints out everything you type. if you type# a newline character though, it will return the text from the# input stream to the program. when you type a "move up", "move down",# or etc character, the function knows that the character is not# a newline character, so it just writes it to the console. this# is why you see stuff like ^[[A when you use the arrow keys on# your keyboard when typing in the input function
write('type ur name belownnhit enter when you're done')# we will read the user's name from the input stream in between# the two newlines
write('x1b[1A')# move up one space
write('x1b[26D')# move left 26 spaces
name = sys.stdin.readline()# read the user's name
write('x1b[1B')# move down 1 space
write(name)# write the user's name to the console output
Ejemplo 2: Python mueve el mouse
import mouse
# Number of pixels to move by on x and y axis
x =1
y =2
mouse.move(x, y)
Sección de Reseñas y Valoraciones
Recuerda que puedes dar recomendación a este post si te fue de ayuda.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)