Reputation: 51
I have a string A:
import keyboard
A = "keyboard.press_and_release('left windows+R')"
But, I want it to work as a function. If I call A, then it should press Windows Key and R key present on y keyboard.
Upvotes: 0
Views: 63
Reputation: 311853
You can use eval
:
a = "keyboard.press_and_release('left windows+R')"
eval(a)
Upvotes: 1
Reputation: 2304
Try using eval
. See https://docs.python.org/3.6/library/functions.html#eval
or What does Python's eval() do?
import keyboard
A = "keyboard.press_and_release('left windows+R')"
eval(A)
Upvotes: 0