Python 从没有括号的文件中提取IP
我有一个hosts文件,例如 美国东部-134.192.0.54 美国西部-150.18.56.1 在尝试取出IP进行Ping测试时,我使用了以下代码:Python 从没有括号的文件中提取IP,python,regex,Python,Regex,我有一个hosts文件,例如 美国东部-134.192.0.54 美国西部-150.18.56.1 在尝试取出IP进行Ping测试时,我使用了以下代码: hosts = open('hosts','r') for line in hosts: temp=line.split()[1:] print(temp) 但它会显示我['34.192.0.54']作为输出,但我只需要 34.192.0.54 运行ping测试。我还可以在代码中添加什
hosts = open('hosts','r')
for line in hosts:
temp=line.split()[1:]
print(temp)
但它会显示我['34.192.0.54']作为输出,但我只需要
34.192.0.54
运行ping测试。我还可以在代码中添加什么来获得所需的输出?您是否使用带有最大/最小线程约束的workmanager和相应的OSB服务? 每个托管服务器的队列默认为16个使用者。如果有多个OSB服务连接到同一队列,则使用者计数将是16的倍数。
唯一的可能性是,如果有某个WM或任何其他应用程序连接到此队列。只需删除拆分中的
:
主机文件:
us-east-1 34.192.0.54
us-west-1 50.18.56.1
#!/usr/bin/python
hosts = open('hosts','r')
for line in hosts:
temp=line.split()[1]
print temp
代码:
us-east-1 34.192.0.54
us-west-1 50.18.56.1
#!/usr/bin/python
hosts = open('hosts','r')
for line in hosts:
temp=line.split()[1]
print temp
输出:
34.192.0.54
50.18.56.1