简体   繁体   English

在Python中如何在调用函数中使用变量?

[英]In Python how to use variables in call function?

I am using Python on Ubuntu. 我在Ubuntu上使用Python。 call(["xdotool", "mousemove", "500","600"]) works fine. call(["xdotool", "mousemove", "500","600"])工作正常。

But if x=500 , y=600 , 但如果x=500y=600

call(["xdotool", "mousemove", "x","y"]) does not work. call(["xdotool", "mousemove", "x","y"])不起作用。

What should be the syntax of x and y ? xy的语法应该是什么?

use it like this 像这样使用它

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

x and y are variables which are pointing to data. xy是指向数据的变量。 But when you say, "x" and "y" , you are passing the data itself. 但是当你说"x""y" ,你正在传递数据本身。

Remove the quotes. 删除引号。 If you keep quotes, it will treat as a string. 如果你保留引号,它将被视为一个字符串。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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