-
Notifications
You must be signed in to change notification settings - Fork 58
Description
from mpython import*
import json
import urequests # urequests模块是一个用于网络访问的模块
WIFI_SSID = "Tenda_888"
WIFI_PASS = "88888888"
mywifi=wifi()
mywifi.connectWiFi(WIFI_SSID, WIFI_PASS) #连接 WiFi 网络
url_ip ="http://ip-api.com/json/" #添加请求地址
rsp=urequests.get(url_ip) #发送get请求
ipJson=rsp.text
ipDict=json.loads(ipJson)
oled.DispChar('国家:%s' % ipDict['country'],0,5) #将国家信息显示到OLED显示屏上
oled.show()
oled.DispChar('城市:%s' % ipDict['city'],0,25) #将城市信息显示到OLED显示屏上
oled.show()
oled.DispChar('IP:%s' % ipDict['query'],0,45) #将IP地址信息显示到OLED显示屏上
oled.show()
Traceback (most recent call last):
File "main.py", line 11, in
File "urequests.py", line 169, in get
File "urequests.py", line 71, in request
OSError: -202