gam*_*rga 3 python parsing text line
我的代码是:
from ipwhois import IPWhois
import pprint
obj = IPWhois('74.125.227.206')
results = obj.lookup_rws()
pprint.pprint(results)
它返回:
{'asn': '15169',
 'asn_cidr': '74.125.227.0/24',
 'asn_country_code': 'US',
 'asn_date': '2007-03-13',
 'asn_registry': 'arin',
 'nets': [{'abuse_emails': 'arin-contact@google.com',
           'address': '1600 Amphitheatre Parkway',
           'cidr': '74.125.0.0/16',
           'city': 'Mountain View',
           'country': 'US',
           'created': '2007-03-13T12:09:54-04:00',
           'description': 'Google Inc.',
           'handle': u'NET-74-125-0-0-1',
           'misc_emails': None,
           'name': 'GOOGLE',
           'postal_code': '94043',
           'range': u'74.125.0.0 - 74.125.255.255',
           'state': 'CA',
           'tech_emails': 'arin-contact@google.com',
           'updated': '2012-02-24T09:44:34-05:00'}],
 'query': '74.125.227.206',
 'raw': None}
python中从输出打印一行的最佳或最简单的方法是什么?
例如:
'name': 'GOOGLE', 
或者 'abuse_emails': 'arin-contact@google.com',
任何帮助,将不胜感激!!
results 已经是字典,所以只需获取您想要的键和值。
from ipwhois import IPWhois
obj = IPWhois('74.125.227.206')
results = obj.lookup_rws()
print(results['nets'][0]['name'])
| 归档时间: | 
 | 
| 查看次数: | 4745 次 | 
| 最近记录: |