This commit is contained in:
dengrb1
2023-05-05 17:21:49 +08:00
committed by GitHub
parent fbb86371cf
commit 7b82a4c4e9

32
wifi.py Normal file
View File

@@ -0,0 +1,32 @@
import socket
from time import sleep
import os
def is_connected():
try:
# 使用百度的IP地址进行连接测试
socket.create_connection(("www.baidu.com", 80))
return True
except OSError:
pass
return False
def open_exe(exe_name):
ml = os.getcwd()
if os.path.exists(ml, f"{exe_name}.exe"):
os.system(f"start {exe_name}.exe")
else:
pass
pass
# mainloop
print('正在启动检测程序...')
sleep(0.22222)
if is_connected():
print("网络已连接,正在启动主程序!!")
sleep(0.33)
open_exe('client')
else:
print("网络未连接,无法使用")