ルーチン説明 14-WiFi-Shield->DNS

# DNS Example
#
# 此示例显示如何通过DNS获取网站的IP地址。

import network
import time
import socket

SSID = ""  # Network SSID 填入要连接的WIFI名称
KEY = ""  # Network key 填入WIFI密码

# 初始化wlan模块并连接到网络
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(SSID, KEY)

while not wlan.isconnected():
    print('Trying to connect to "{:s}"...'.format(SSID))
    time.sleep_ms(1000)

# 我们现在通过DHCP应该有一个有效的IP
print("WiFi Connected ", wlan.ifconfig())
print(socket.getaddrinfo("www.google.com", 80)[0][4])

results matching ""

    No results matching ""