python for loops [closed]
Im trying to use this http://code.google.com/p/pywhois/ along with the socket.gethostbyaddr .
import socket
import pywhois
revip = socket.gethostbyaddr('50.57.48.133')
whois = pywhois.whois(rev开发者_如何学编程ip[0])
for i in whois.emails:
print
Gives me three lines of nothing. Im trying to print out the emails from the whois query. The data stored inside whois.emails is
['josh.odom@rackspace.com', 'josh.odom@rackspace.com', 'support@clickandname.com']
Whats going wrong here?
To get the code working, you need to add i after print:
for i in whois.emails:
print i # you may see print(i) because in Python 3 print is a function.
# and it does not matter in Python < 3
To get this format
['josh.odom@rackspace.com', 'josh.odom@rackspace.com', 'support@clickandname.com']
you call print on the entire list (no looping):
print whois.emails
print i
That should solve your problem.
Maybe you should do print i
instead of just print
.
精彩评论