例程讲解14-WiFi-Shield->dns
# DNS Example
#
# 此示例显示如何通过DNS获取网站的IP地址。
import network, usocket
# AP info
SSID='' # Network SSID
KEY='' # Network key
# 初始化wlan模块并连接到网络
print("Trying to connect... (may take a while)...")
wlan = network.WINC()
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)
# 我们现在通过DHCP应该有一个有效的IP
print(wlan.ifconfig())
print(usocket.getaddrinfo("www.google.com", 80)[0][4])