import pyautogui as pg
import time
def mouse_coordinate():
print('Press Ctrl-C to quit.')
try:
while True:
# 获取鼠标下x, y坐标
x, y = pg.position()
# 调整x, y输出格式
positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
print(positionStr, end='')
time.sleep(0.2)
print('\b' * len(positionStr), end='', flush=True)
except KeyboardInterrupt:
print('\nDone.')
if __name__ == '__main__':
mouse_coordinate()
07-06
1225
01-23
988