獲得ip的小腳本

#!/usr/bin/env python
import requests
import json
r_json = requests.get('https://myip.ipip.net/json').text
weather_dict = json.loads(r_json)
location = weather_dict.get('data').get('location')
country = location[0]
province = location[1]
city = location[2]
isp = location[4]


def toString():
    print('我的國家是:[' + country + ']')
    print('我的省份是:[' + province + ']')
    print('我的城市是:[' + city + ']')
    print('我的運營商是:[' + isp + ']')


toString()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章