penuel
# -*- coding:utf-8 -*-
#@author:YouLei
#@time:2020/05/27=11:20
import time
import socket
time.sleep(2)

#获取本级制定接口的ip地址
def get_ip_address():
        s =socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
        #print(s)
        s.connect(("1.1.1.1",80))
        #print(s)
        ipaddr=s.getsockname()[0]
        s.close()
        return ipaddr

try:
    ip=get_ip_address()#获取 wlan0的网卡
    print("wln0_IP:",ip)
except:
    print("错误:没有连接Wi-Fi!!!!")
    time.sleep(5)
    exit()
time.sleep(10)


"""

#!/bin/sh

python3 /home/pi/tools/ip.py 
echo "ok"

1、修改后缀sh变成command:hello.sh->hello.command

2、修改可执行权限:chmod u+x hello.command
"""

分类:

技术点:

相关文章:

  • 2021-08-17
  • 2021-12-30
  • 2021-06-03
  • 2021-04-08
  • 2021-11-20
  • 2021-11-20
  • 2021-05-29
  • 2021-11-20
猜你喜欢
  • 2021-11-20
  • 2022-01-12
  • 2022-02-10
  • 2021-11-20
  • 2021-06-14
  • 2021-07-12
  • 2021-10-18
相关资源
相似解决方案