#!/usr/bin/python3
from urllib.request import urlopen
for line in urlopen('http://freeapi.ipip.net/118.28.8.8'):
line = line.decode('utf-8') # Decoding the binary data to text.
print(line)
a=eval(line)
print(a[0], a[1], a[2], a[3],a[4])
from urllib.request import urlopen
for line in urlopen('http://freeapi.ipip.net/118.28.8.8'):
line = line.decode('utf-8') # Decoding the binary data to text.
print(line)
a=eval(line)
print(a[0], a[1], a[2], a[3],a[4])
该接口由ipip.net提供,这里仅演示python的语法,需要使用python3中的urlopen函数。