编程语言
首页 > 编程语言> > python gotoxy

python gotoxy

作者:互联网

import ctypes
import os
STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
STD_ERROR_HANDLE = -12

os.system('cls')

class COORD(ctypes.Structure):
    _fields_ = [("X", ctypes.c_short), ("Y", ctypes.c_short)]

    def __init__(self, x, y):
        self.X = x
        self.Y = y
def gotoxy(x,y):
    hOut = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
    ctypes.windll.kernel32.SetConsoleCursorPosition(hOut,COORD(x,y))

gotoxy(5, 5)
print("test")

效果

标签:STD,__,HANDLE,python,self,gotoxy,ctypes
来源: https://www.cnblogs.com/WhXcjm/p/14644044.html