简体   繁体   中英

In Python how to use variables in call function?

I am using Python on Ubuntu. call(["xdotool", "mousemove", "500","600"]) works fine.

But if x=500 , y=600 ,

call(["xdotool", "mousemove", "x","y"]) does not work.

What should be the syntax of x and y ?

use it like this

call(["xdotool", "mousemove", str(x), str(y)])

x and y are variables which are pointing to data. But when you say, "x" and "y" , you are passing the data itself.

Remove the quotes. If you keep quotes, it will treat as a string.

call(["xdotool", "mousemove", "500","600"])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM