I am new on python and I am trying to do something like this:
import pyautogui
import time
youLocate = pyautogui.locateCenterOnScreen('you.PNG', confidence=0.9, grayscale=False)
time.sleep(3)
if youLocate == "None":
print("Nothing")
else:
print("Visible")
The value of youLocate variable according to the console is None string. But instead of printing "nothing", it print the else statement which is "visible".
I also tried to do something like this but did not work:
if print(youLocate) == "None":
print("Nothing")
else:
print("Visible")
Is there any ways to get the value of print() so that i can make if statement?
this function: pyautogui.locateCenterOnScreen('you.PNG', confidence=0.9, grayscale=False)
returns "None" according to the console. I want to get the value of it and make it as a variable or compare the value of it using if statement.
Thank you!
CodePudding user response:
"None"
and None
are different things one is a string that contains None and the other is Nonetype
so you can compare it like so
if youLocate is None:
print("Nothing")
else:
print("Visible")