你能帮我用trim修剪它的结果
(0, None, 1492333402, (b'sendgrid.net',))
(0, None, 1492331992, (b'internal-prolb-1409411760.eu-west-1.elb.amazonaws.com',))
(0, None, 1492333397, (b'edge.ssl.deals.souq.com',))
这种格式。
sendgrid.net
internal-prolb-1409411760.eu-west-1.elb.amazonaws.com
edge.ssl.deals.souq.com
下面是我的代码
#!/usr/bin/python
import sys
import socket
import adns
import time
from dns import resolver,reversename
results = []
hostlist = sys.argv[1]
hostarray = []
s=adns.init()
with open(hostlist, 'r') as f:
for hostname in f:
if hostname.split(':'):
hostarray.append(hostname.split(':')[0])
else:
hostarray.append(hostname)
for hostname in hostarray:
try:
ip = socket.gethostbyname(hostname.strip())
except socket.gaierror:
try:
ip = socket.gethostbyname('.'.join(hostname.strip().split('.')[1:]))
except socket.gaierror as e:
continue
except socket.error as e:
continue
results.append((ip, hostname.strip()))
def main():
for (ip, hostname) in sorted(results, key=lambda item: socket.inet_aton(item[0])):
x = (s.synchronous(hostname,adns.rr.CNAME))
print (x)
main()
我的循环结束后,我得到的结果如下。 请帮忙整理一下,谢谢
答案 0 :(得分:0)
directionsDisplay = new google.maps.DirectionsRenderer({
draggable: true
});
答案 1 :(得分:0)
您想要访问元组中元组中的字符串。可以使用与列表相同的方式访问元组。
tuple[3][0]
可以使用
解码字符串string.decode()