How to play Mahjong?
admin
2/25/2025
14 views
预计阅读时长 2 分钟
We Love Mahjong~
Test article page
Test article image1
Test article image2
test markdown
import requests
def get_public_ip():
try:
response = requests.get("https://api.ipify.org")
if response.status_code == 200:
return response.text
else:
return "无法获取公网IP"
except Exception as e:
return str(e)
Test article image2``Test article image2
import socket
def get_private_ip():
try:
# 创建一个UDP套接字
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80)) # 连接到一个外部地址
ip = s.getsockname()[0] # 获取本机IP
s.close()
return ip
except Exception as e:
return str(e)
print("内网IP地址:", get_private_ip())