开发者

python for loops [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜