'Can I get the mouse position with a different format

I am trying to get the position of my mouse, but make it print just the coordinates like

1000, 1000

Not like

Point(x=1212, y=621)

My Code:


x = pyautogui.position()


Solution 1:[1]

You can do it in this way:

import pyautogui

x,y = pyautogui.position()
print(f"x:{x}, y:{y}")

Output:

x:479, y:441

If you don't want x and y to appear then you can use:

import pyautogui

x,y = pyautogui.position()
print(x, y)

Output:

479, 441

Solution 2:[2]

You can use

x, y = pyautogui.position()
print(x)
print(y)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2