Python Ip地址更改为整数

Python Ip地址更改为整数,python,python-3.7,philips-hue,Python,Python 3.7,Philips Hue,我正在制作一个脚本,将使用子流程模块ping一个ip地址。但当我试着运行它时,它说: Traceback (most recent call last): File "C:\Users\YUZi5\OneDrive\Desktop\huetest.py", line 99, in <module> subprocess.run("ping", int(hhip), "/dev/null", capture_output=True) #doesnt work rn Valu

我正在制作一个脚本,将使用子流程模块ping一个ip地址。但当我试着运行它时,它说:

Traceback (most recent call last):
  File "C:\Users\YUZi5\OneDrive\Desktop\huetest.py", line 99, in <module>
    subprocess.run("ping", int(hhip), "/dev/null", capture_output=True) #doesnt work rn
ValueError: invalid literal for int() with base 10: '192.168.1.109'

查看if operation==('6')以查看我试图添加的特定部分。

您需要在
子流程中以列表形式传递参数。运行
方法。那你的台词呢

subprocess.run("ping", int(hhip), "/dev/null", capture_output=True)
应改为

subprocess.run(["ping", hhip, "/dev/null"], capture_output=True)

你打算
int('192.168.1.109')
做什么?我打算在ping命令后将该部分输入cmd,因此在cmd中它应该是ping 192.168.1.109,例如,你是否在没有
int()
的情况下尝试过类似于
子流程。运行(“ping”,hhip,/dev/null,capture\u output=True)
?是的,我现在就尝试一下。不起作用,当我在没有int(hhip)的情况下运行它时,它说buffsize必须是一个整数
subprocess.run(["ping", hhip, "/dev/null"], capture_output=True)